akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int N, A, B, C;
vector<int> lens;

int dfs(int cur, int a, int b, int c) {
    if(cur == N) {
        if(a == 0 || b == 0 || c == 0) {
            return 1 << 29;
        } else {
            return abs(A - a) + abs(B - b) + abs(C - c);
        }
    } else {
        int res1 = dfs(cur + 1, a + lens[cur], b, c);
        if(a != 0) res1 += 10;

        int res2 = dfs(cur + 1, a, b + lens[cur], c);
        if(b != 0) res2 += 10;

        int res3 = dfs(cur + 1, a, b, c + lens[cur]);
        if(c != 0) res3 += 10;

        int res4 = dfs(cur + 1, a, b, c);

        return min({res1, res2, res3, res4});
    }
}

int main() {
    cin >> N >> A >> B >> C;
    REP(i, N) {
        int tmp;
        cin >> tmp;
        lens.emplace_back(tmp);
    }
    cout << dfs(0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
abcs = [None for _ in range(n)]

# dp[i][j][k] i 番目 連続/未連続 abc
for i in range(n):
    abcs[i] = list(map(int, input().split()))

dp = [abcs[0]] + [[0, 0, 0] for _ in range(n - 1)]
for i in range(1, n):
    for k in range(3):  # next abc
        for j in range(3):  # previous abc
            if k != j:
                dp[i][k] = max(dp[i][k], dp[i - 1][j] + abcs[i][k])
print(max(dp[i]))
# これは三日以上
# for i in range(n):
#     for k in range(3):  # next abc
#         for j in range(2):  # j == 0: 未連続, j == 1: 連続
#             for l in range(3):  # previous abc
#                 if k == l and j == 1:
#                     dp[i][j][k] = dp[i - 1][0][l] + abcs[i][k]
#                 elif k != l:
#                     dp[i][j][k] = max(dp[i][j][k],
#                                       dp[i - 1][j][l] + abcs[i][k])
#                 print(dp[i])


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

int main() {
 
  int N;
  cin >> N;
  
  vector<vector<int>> D(N, vector<int>(2));
  for(int i=0; i<N; i++){
    for(int j=0; j<2; j++){
      cin >> D.at(i).at(j);
    }
  }
  
  vector<int> ans(N);
  for(int i=0; i<N; i++){
    if(D.at(i).at(0) == D.at(i).at(1)){
      ans.at(i) = 1;
    }
    else{
      ans.at(i) = 0;
    }
  }
 
  int cnt = 0;
  for(int i=0; i<N-2; i++){
    if(ans.at(i) == 1 && ans.at(i+1) ==1 && ans.at(i+2)){
      cnt++;
    }
  }
  
  if(cnt == 0){
   cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  
  
}


Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int d,c;
  cin>>d>>c;
  cout<<d*c<<'\n';
  return(0);
}


Measured memory_bytes: 3204
n=int(input())
k=int(input())

li=[]
for i in range(1, n+1):
    li.append(i)
    
#print(li)
for i in range(k):
    x=list(map(int,input().split(",")))
    li[x[0]-1]^=li[x[1]-1]
    li[x[1]-1]^=li[x[0]-1]
    li[x[0]-1]^=li[x[1]-1]
    #print(*li)
    
for i in range(n):
    print(li[i])


Measured memory_bytes: 5596
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n + 1);
  B = malloc(sizeof(short)*n + 1);
  for(i=0; i<=VMAX; i++) C[i]=0;

  for(i=0; i<n; i++){
    scanf("%hu", &A[i+1]);
    C[A[i+1]]++;
  }
  for(i=1; i<=VMAX; i++) C[i] = C[i] + C[i-1];
  for(j=1; j<=n; j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  for(i=1; i<=n; i++){
    if(i>1) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 9588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

vector<int> pf(int n) {
    vector<int> primes;
    if (n%2 == 0) {
        primes.push_back(2);
        while (n%2 == 0) n /= 2;
    }
    for (int i=3; i*i<=n; i+=2) {
        if (n%i) continue;
        primes.push_back(i);
        while (n%i == 0) n /= i;
    }
    if (n != 1) primes.push_back(n);

    return primes;
}

int main() {
    int n;
    cin >> n;
    int all_gcd;
    bool pc = true;
    set<int> prime_check;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        all_gcd = i==0?a:gcd(all_gcd, a);

        if (!pc) continue;
        vector<int> primes = pf(a);
        for (auto i : primes) {
            if (prime_check.find(i) != prime_check.end())
                pc = false;
            prime_check.insert(i);
        }
    }

    if (pc)
        cout << "pairwise coprime" << endl;
    else if (all_gcd == 1)
        cout << "setwise coprime" << endl;
    else
        cout << "not coprime" << endl;
}


Measured memory_bytes: 6796
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,j,n,m) for(int i=j;i<n;i+=m)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

int main(){
  IOS();
  ll n;
  cin>>n;
  if(n<1000) cout<<"ABC"<<endl;
  else cout<<"ABD"<<endl;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	a := nextInts(n - 1)

	ans := make([]int, n)
	for i := range a {
		ans[a[i]-1]++
	}

	for i := range ans {
		puts(ans[i])
	}
}


Measured memory_bytes: 6664
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]"):
    play = N - sum(A)
    print(play if play >= 0 else -1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9964
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	public static void main(String[] args) {
		int a=scan.nextInt();
		int b=scan.nextInt();
		int cnt=0;
		for(int i=0;i<a;i++) {
			int c=scan.nextInt();
			if(c>=b)cnt++;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 45852
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
int N, M, fa[10005];
struct Edge {
	int u, v;
	double d;
}edge[50000010];
struct Node {
	double x, y;
}node[10005];
bool cmp(Edge x1, Edge x2)
{
	return x1.d > x2.d;
}
int find(int x)
{
	if (x == fa[x])
		return x;
	else
		return fa[x] = find(fa[x]);
}
double Dist(Node a, Node b)
{
	return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
}
int main()
{
	while (scanf("%d %d", &N, &M) != EOF)
	{
		for (int i = 1; i <= N; i++)
			fa[i] = i;
		for (int i = 1; i <= N; i++)
			scanf("%lf %lf", &node[i].x, &node[i].y);
		double sum = 0.0;
		for (int i = 0; i < M; i++)
		{
			int a, b;
			scanf("%d %d", &a, &b);
			edge[i].u = a;
			edge[i].v = b;
			edge[i].d = Dist(node[a],node[b]);
			sum += edge[i].d;
		}
		sort(edge, edge + M, cmp);
		double s = 0.0;
		for (int i = 0; i<M; i++)
		{
			int x, y;
			x = find(edge[i].u);
			y = find(edge[i].v);
			if (x != y)
			{
				if (x>y)
					fa[x] = y;
				else
					fa[y] = x;
				s = s + edge[i].d;
			}
			else
				continue;
		}
		double ans = 0.0;
		ans = sum - s;
		printf("%.3f\n", ans);
	}
	return 0;
}



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

int main() {
  ll N;
  cin>>N;
  if(N%2==1){cout<<0<<endl;}
  else{
    ll ans=0;
    N/=2;
    while(N>0){
      ans+=N/5;
      N/=5;
    }
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> en(2000010);
  for(int i = 0; i < N; i++){
   cin >> en[i]; 
  }
  
  sort(en.begin(), en.end());
  reverse(en.begin(), en.end());
  
 long long dmg = 0;
  for(int i = K; i < N; i++){
    dmg += en[i];
  }
 cout << dmg << endl;
  
}


Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
#include<regex>
#include<numeric>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	for (int i = 0; i < n; i++) {
		if (i == k - 1) {
			if (s[i] == 'A')cout << 'a';
			if (s[i] == 'B')cout << 'b';
			if (s[i] == 'C')cout << 'c';
		}
		else cout << s[i];
	}
	cout << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
#include <algorithm>
#include <cctype>

using namespace std;

int main(){
	string s;
	int k;
	cin >> k >> s;
	if(s.size() <= k){
		cout << s << endl;
	}else{
		cout << s.substr(0,k) << "..." << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    vector<int> v(100005);
    while (n--) {
        int x;
        cin >> x;
        ++v[x];
    }

    int ans = 0;
    for (int i = 0; i <= 100000; ++i) {
        ans = max(ans, v[i] + v[i+1] + v[i+2]);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 640
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9+5;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,ans=0,cnt;
  cin >> n;
  ans+=n*(n+1)/2;
  for(ll i=2; i<=n; i++) {
    cnt=i;
    while(cnt<=n) {
      ans+=cnt;
      cnt+=i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
	class Program
	{
		public static void Main(string[] args)
		{
			int n=int.Parse(Console.ReadLine());
			int[] array= new int[n];
			for(int k=0;k<n;k++)
			{
				array[k]=int.Parse(Console.ReadLine());
			}
			int cnt=0;
			int m=1;//?????£??????????????°???h=3???m?????????/??? h<n???
			List<int> G=new List<int>();//?????£??????????´???????????????£???????????????????????????????????????????????£??????
			for(int gap=2;(int)((Math.Pow(3,gap)-1)/2)<n;gap++)
			{			
				m++;
			}
			
			
			for(int i=0;i<m;i++)
			{
				G.Add((int)((Math.Pow(3,i+1)-1)/2));
			}
			for(int j=0;j<m;j++)
			{
				cnt+=sort( array, n, G[m-1-j]);//?????\?????????????????????
			}
			//?????????????????????m???????????????G[i]????????????????????§???????????????G?????¨????????´??????count?????????
			//????????????????????????????????????
			Console.WriteLine(m);
			for(int o=0;o<m-1;o++)
			{
				Console.Write(G[m-1-o]+" ");
			}
			Console.Write(G[0]+"\r\n");//???????????§?????????
			Console.WriteLine(cnt);//?????????
			for(int l=0;l<n;l++)
			{
				Console.WriteLine(array[l]);
			
			}
			
			
		}
		public static int sort(int [] A,int n,int g)
		{
			int count=0;//??????????????°
			for (int k=0;k<g;k++)
			{
				
			for(int i=k+g;i<n;i+=g)
			{
				
				int v=A[i];
				int j=i-g;
				while(j>=0&&A[j]>v)
				{
					A[j+g]=A[j];
					j=j-g;
				count ++; //????????????????????§????????????????????§??????????????¢??????
				A[j+g]=v;//????????????A[j]???????????????????§?????????????????????\????????????
				//??????????????????????°?????????????????????´?????????????????£?????????????????????????´??????´???????????????????°?????????????????????????0
				//?????????????????????????????\???
				}
				
			}
			}
			return count;
		}
		
	}
	

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

int D; long long G;
long long P[20], C[20];

int main () {
	std::ios::sync_with_stdio (0);
	std::cin >> D >> G;
	for (int i = 0; i < D; ++i) std::cin >> P[i] >> C[i];
	long long ans = 1E18;
	for (int mask = 0; mask < (1 << D); ++mask) {
		long long res = 0, cnt = 0;
		for (int i = 0; i < D; ++i) if ((mask >> i) & 1) {
			res += P[i] * 100 * (i + 1) + C[i];
			cnt += P[i];
		}
		if (res >= G) {
			ans = std::min (ans, cnt);
			continue;
		}
		for (int i = D - 1; i >= 0; --i) if (!((mask >> i) & 1)) {
			for (int j = 0; j < P[i]; ++j) {
				res += (i + 1) * 100;
				++cnt;
				if (res >= G) {
					ans = std::min (ans, cnt);
					goto orz;
				}
			}
		}
orz:;
	}
	std::cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] v = new int[n];
		for (int i = 0; i < n; i++) {
			v[i] = sc.nextInt();
		}
		int ans = -1000000000;
		int r = Math.min(n, k);
		for (int i = 0; i <= r; i++) {
			for (int j = 0; j <= r - i; j++) {
				int d = k - i - j;
				ArrayList<Integer> li = new ArrayList<>();
				for (int l = 0; l < i; l++) {
					li.add(v[l]);
				}
				for (int l = 0; l < j; l++) {
					li.add(v[n - 1 - l]);
				}
				Collections.sort(li);
				for (int l = 0; l < Math.min(d, li.size()); l++) {
					if (li.get(l) < 0) {
						li.set(l, 0);
					} else {
						break;
					}
				}
				int tmp = 0;
				for (int l = 0; l < li.size(); l++) {
					tmp += li.get(l);
				}
				ans = Math.max(ans, tmp);
			}
		}
		System.out.println(ans);
	}
}


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

int main(){
    ll N; cin>>N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++){
        cin>>A[i];
    }
    ll step=0,height=0;
    for (ll i = 0; i < N-1; i++){
        ll now=A[i]-A[i+1];
        if(A[i]>A[i+1]){
            step+=now;
            A[i+1]+=now;
        }
    }
    cout<<step<<endl;
}

Measured memory_bytes: 4836
#include <stdio.h>
#include <iomanip>
#include <time.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <queue>
#include <vector>
#define mod 1000000007
#define ll long long
#define pi acos(-1)
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string s[200005];
	for(int i = 0; i < n; i++)
		cin>>s[i];
	sort(s,s+n);
	ll sum = 0;
	for(int i = 1; i < n; i++){
		if(s[i]!=s[i-1])
			sum++;
	}
	cout<<sum+1;
	
	return 0;
}

Measured memory_bytes: 9900
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k, q;
	cin >> n >> k >> q;
	for (int i = 1; i <= q; i++)
	{
		int x;
		cin >> x;
		a[0]--;
		a[x]++;
		a[x + 1]--;
	}
	for (int i = 1; i <= n; i++) a[i] += a[i - 1];
	for (int i = 1; i <= n; i++)
	{
		a[i] += k;
		if (a[i] > 0) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
	using namespace std;
	#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
	#define ll long long int


	int main()
	{
		FAST;
		//ll testcase;
		//cin>>testcase;
		//for(ll t=0;t<testcase;t++)
		{
			//use long long
			//donot memeset other than 0 or 1 or -1
			//segmentation fault-> check for uninitialized global variable or out of bounds
			//always check for bottle neck (whether original constraints can be reduced by introducing some condition)
			//dont rush to writing code think through the logic	
			ll n;
			cin>>n;
			ll a[n];
			for(ll i=0;i<n;i++)
				cin>>a[i];
			int count[1000000+2];
			memset(count,0,sizeof(count));
			int max=*max_element(a,a+n);
			for(int i=0;i<n;i++)
			{
				int t=a[i];
				while(t<=max)
				{
					count[t]++;
					t+=a[i];
				}
			}
			int ans=0;
			for(int i=0;i<n;i++)
			{
				if(count[a[i]]<=1)
					ans++;
			}
			
			
			cout<<ans<<'\n';
		}
		return 0;
	}



































Measured memory_bytes: 9068
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
const int N=1e6+11;
int a[N],b[N];
int np[N],p[N],mn[N],tot;
int n;
int main(){
	int i,j,k;
	for(i=2;i<N;++i){
		if(!np[i]){
			p[++tot]=i;
			mn[i]=i;
		}
		for(j=1;j<=tot&&(k=i*p[j])<N;++j){
			np[k]=1;
			mn[k]=p[j];
			if(i%p[j]==0){
				break;
			}
		}
	}
	int n,rr=1,g;
	cin>>n;
	for(i=1;i<=n;++i)cin>>a[i];
	g=a[n];
	for(i=n;i;--i){
		int x=a[i],y;
		g=__gcd(g,x);
		while(x>1){
			y=mn[x];
			rr&=!b[y];
			b[y]=1;
			while(x%y==0)x/=y;
		}
	}
	if(rr){
		puts("pairwise coprime");
	}else if(g==1){
		puts("setwise coprime");
	}else{
		puts("not coprime");
	}
}

Measured memory_bytes: 19564
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Apr 26 21:13:50 JST 2020
 **/

signed main() {
    Int n;
    std::cin >> n;
    std::set<std::string> s;
    REP(i, n) {
        std::string t;
        std::cin >> t;
        s.insert(t);
    }
    std::cout << s.size() << std::endl;
}


Measured memory_bytes: 19276
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    char[] s = br.readLine().toCharArray();
    if (s[2] == s[3] && s[4] == s[5]){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
 
const int maxn = 1111;
char s[maxn];
int vis[maxn];
 
signed main() {
  // freopen("in", "r", stdin);
  while(~scanf("%s", s)) {
    memset(vis, 0, sizeof(vis));
    int tot = 0;
    for(int i = 0; s[i]; i++) {
      if(s[i] >= 'A' && s[i] <= 'Z') tot++;
      vis[s[i]]++;
    }
    if(tot != 2) {
      printf("WA\n");
      continue;
    }
    if(s[0] != 'A') {
      printf("WA\n");
      continue;
    }
    if(vis['A'] != 1 || vis['C'] != 1) {
      printf("WA\n");
      continue;
    }
    tot = 0;
    int n =strlen(s);
    for(int i = 2; i <= n - 2; i++) {
      if(s[i] == 'C') tot++;
    }
    if(tot) printf("AC\n");
    else printf("WA\n");
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
public class Program {
	public static void Main() {
		int n = int.Parse(Console.ReadLine());
		for(int i = 0; i < n; i++) {
			string[] s = Console.ReadLine().Split();
			int[] a = new int[3];
			for(int j = 0; j < 3; j++) a[j] = int.Parse(s[j]);
			Array.Sort(a);
			Console.WriteLine(((a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) ? "YES" : "NO"));
		}
	}
}

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

void accumlate(){
}


int main(){
    int N; cin >> N;
    int w[N];
    for(int i=0;i<N;i++) cin >> w[i];
    int sum[N+1] = {};
    for(int i=0;i<N;i++){
        sum[i+1] = sum[i]+w[i];
    }
    int ans = 1e9;
    for(int i=1;i<N;i++) ans = min(ans,abs((sum[N]-sum[i])-sum[i]));
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int n = sc.nextInt();
		int x = 0;
		int y = 0;
				
		
		
		for(int i=0; i<n; i++){
			int x1 = sc.nextInt();
			int y1 = sc.nextInt();
			int a = sc.nextInt();
			if(a==1&&x<x1){
				x = x1;
			}else if(a==2&&w>x1){
				w = x1;
			}else if(a==3&&y<y1){
				y = y1;
			}else if(a==4&&h>y1){
				h = y1;
			}
		}
		
		if(x<w&&y<h){
			System.out.println((w-x)*(h-y));
		}else{
			System.out.println("0");
		}
		
		
	}

}

Measured memory_bytes: 10836
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int H=sc.nextInt();
            int W=sc.nextInt();
            if(H==0 || W==0){
                break;
            }
            for(int x=0;x<W;x++){
                System.out.print("#");
            }
            System.out.println();
            for(int y=1;y<H-1;y++){
                System.out.print("#");
                for(int x=1;x<W-1;x++){
                System.out.print(".");
            }
                System.out.print("#");
                System.out.println();
            }
            for(int x=0;x<W;x++){
                System.out.print("#");
            }
            System.out.println();
            System.out.println();
        }
    }
}


Measured memory_bytes: 32660
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(m);
    for(auto &I:a){cin>>I; I--;}
    ll l=0;
    vector<ll> L(n,0);
    for(int i=1;i<=n;i++){
        while(l<m && a[l]<i){l++;}
        if(l==0){L[i-1]=E;}
        else{L[i-1]=i-a[l-1];}
    }
    sort(L.begin(),L.end(),greater<ll>());
    ll q;
    cin>>q;
    while(q--){
        ll l;
        cin>>l;
        if(l>=n){cout<<1<<endl;}
        else if(L[l]==E){cout<<-1<<endl;}
        else{cout<<L[l]<<endl;}
    }
    
    
    
    return 0;
}



Measured memory_bytes: 4436
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mss map <string,string>
#define msl map <string,ll>
#define mll map <ll,ll>
#define mcl map <char,ll>
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}
long long  int exponentiation(long long  int base, long long  int exp) 
{ 
  if (exp == 0) 
    return 1; 
 
  if (exp == 1) 
    return base % N; 
  long long int t = exponentiation(base, exp / 2); 
  t = (t * t); 
  if (exp % 2 == 0) 
    return t;
  else  
    return ((base ) * t) ; 
}

int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);

  ll n,m;
  cin>>n>>m;
  ll c=1,ans=0;
  while(c<m){
    c+=n-1;
    ans++;
  }
  cout<<ans;
}







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

int main(){
	int n;
	cin >> n;
	long long int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	long long int l = 2; 
	long long int r = 2;
	for(int i = n-1; i >= 0; i--){
		long long int mini = ceil(1.0*l/a[i]);
		long long int maxi = r/a[i];
		if(mini > maxi	){
			cout << -1 << endl;
			return 0;
		}
		l = a[i]*mini;
		r = a[i]*maxi + a[i]-1;
	}
	cout << l << " " << r << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()

typedef long long ll;

typedef long double ld;

using namespace std;

const ll maxn = 4e3 + 100;
const ll shift = 13e3;
const ll inf = 1e9;

ll n, m, k;

bool AB[maxn * 100];

bool BC[maxn * 100];

bool AC[maxn * 100];

bool in(ll i) {
    return i >= 0 && i < maxn * 100;
}

int main() {
    ll q, w, e, d;
    // pyshnapyshnakaa;
    string a, b, c;
    cin >> a >> b >> c;
    for (q = 0; q < a.length(); q++) {
        for (w = 0; w < b.length(); w++) {
            if (a[q] == '?' || b[w] == '?') {
                continue;
            }
            assert(in(w - q + shift));
            if (a[q] != b[w]) {
                AB[w - q + shift] = 1;
            }
        }
    }
    for (q = 0; q < a.length(); q++) {
        for (w = 0; w < c.length(); w++) {
            if (a[q] == '?' || c[w] == '?') {
                continue;
            }
            assert(in(w - q + shift));
            if (a[q] != c[w]) {
                AC[w - q + shift] = 1;
            }
        }
    }
    for (q = 0; q < b.length(); q++) {
        for (w = 0; w < c.length(); w++) {
            if (b[q] == '?' || c[w] == '?') {
                continue;
            }
            assert(in(w - q + shift));
            if (b[q] != c[w]) {
                BC[w - q + shift] = 1;
            }
        }
    }
    // cout << AC[-2 + shift] << endl;
    // cout << AB[shift + ]
    ll ans = inf;
    for (q = -maxn; q < maxn; q++) {
        for (w = -maxn; w < maxn; w++) {
            // ll sab = q;
            // ll sac = w;
            // ll sbc = w - q;
            ll len =  max((ll)a.length(), (ll)max(q + (ll)b.length(), w + (ll)c.length())) 
            - min(0LL, min(q, w));
            assert(in(-q + shift) && in(-w + shift) && in(q - w + shift));
            if (!AB[-q + shift] && !AC[-w + shift] && !BC[q - w + shift]) {
                // if (q == 2)cout << q << " " << w << endl;
                if (len < ans) {
                    // cout << q << " " << w << endl;
                    ans = len;
                }
                // ans = min(ans, len);
            }
        }
    }
    assert(ans <= a.length() + b.length() + c.length());
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();
		int N = sc.nextInt();
		for(int i = 0; i < N; i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);

		int sm = list.get((N/2)-1);
		int bi = list.get(N/2);

		int ans = 0;

		if(sm == bi)ans = 0;
		else ans = bi - sm;

		System.out.println(ans);
	}
}

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

bool judge(int a){
  int tmp=a;
  int digit5 = ((a-(a%10000))/10000);
  a=(a-digit5*10000);
  int digit4 = ((a-(a%1000))/1000);
  a=(a-digit4*1000);
  int digit3 = ((a-(a%100))/100);
  a=(a-digit3*100);
  int digit2 = ((a-(a%10))/10);
  int digit1 = (a-digit2*10);
  int b = digit1*10000 + digit2*1000 + digit3*100 + digit4*10 + digit5;
  if(b==tmp) return true;
  else return false;
}
int main()
{
  int A,B;
  cin>>A>>B;
  int cnt=0;
  for(int i=A;i<=B;i++){
    if(judge(i)){
      cnt++;
    }
  }
  cout<<cnt;
  
}

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

int main(){
	int n;
	cin >> n ;
	for(int t=0 ; t < n ; t++ ){
		int s, g;
		cin >> s >> g;
		if( g < s && s <= 5 ){
			for(int i=s ; i >= g ; i-- ){
				cout << i;
				(i == g)? cout << endl : cout << " ";
			}
		}else if( s >= 6 && g <= 5 ){
			for(int i=s ; i <= 9 ; i++ ){
				cout << i << " ";
			}
			for(int i=5 ; i >= g ; i-- ){
				cout << i;
				(i == g)? cout << endl : cout << " ";
			}
		}else if( s >= 6 && g >= 6 && g < s ){
			for(int i=s ; i <= 9 ; i++ ){
				cout << i << " ";
			}
			cout << "5 4 3 2 1 ";
			for(int i=0 ; i <= g ; i++ ){
				cout << i;
				(i == g)? cout << endl : cout << " ";
			}
		}else{
			for(int i=s ; i <= g ; i++ ){
				cout << i;
				(i == g)? cout << endl : cout << " ";
			}
		}
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int main(){
  cin >> n;
  int highest = 0, ret = 0;
  for(int i=0; i<n; i++){
    int p; cin >> p;
    highest = max(highest, p);
    ret += p;
    }
  ret -= highest / 2;
  cout << ret << endl;
  return 0;
  }

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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    akari<int> as(n);
    for (int &a : as)
        cin >> a;
    cin >> n;
    akari<int> bs(n), ans;
    for (int &b : bs)
        cin >> b;
    set_intersection(as.begin(), as.end(), bs.begin(), bs.end(), inserter(ans, ans.end()));
    for (int a : ans)
    {
        cout << a << '\n';
    }
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 4708
#include <iostream>

int ahaha (char a[3]) {
    int ans = 0;
    for (int i = 0; i < 4; ++i) {
        if (a[i] == '+') {
            ++ans;
        }
        else {
            --ans;
        }
    }
    return ans;
}
int main () {
    char a[3];
    for (int i = 0;i < 4;++i) {
        std::cin >> a[i];
    }
    int ans = ahaha (a);
    std::cout << ans << std::endl;
}

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

using namespace std;

int main() {
  while (true) {
    int H, W;
    cin >> H >> W;
    if (H + W == 0) {
      break;
    }
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
          cout << '#';
        } else {
          cout << '.';
        }
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1156
N = int(input())
S = []
for _ in range(N):
    S.append(int(input()))
S.sort()
ans = sum(S)
if ans % 10 == 0:
    for s in S:
        if s % 10 != 0:
            print(ans-s)
            exit()
    print(0)
else:
    print(ans)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
    int H,W;
    cin>>H>>W;
    while(H > 0){
        for(int i = 0;i < H;i++){
            for(int j = 0;j<W;j++){
                if(i == 0 || i == H -1){
                    cout<<"#";
                    if(j == W - 1){
                        cout<<""<<endl;
                    }
                }else{
                    if(j == 0 || j == W -1){
                        cout<<"#";
                        if(j == W - 1){
                            cout<<""<<endl;
                        }
                    }else{
                        cout<<".";
                    }
                }
            }
            if(i == H - 1){
                cout<<""<<endl;
            }
        }
        cin>>H>>W;
    }
    return 0 ;
}


Measured memory_bytes: 3080
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n):
  for j in range(i+1,n):
    t=l[i]+l[j]
    idx=bisect.bisect_left(l,t)
    ans+=max(0,idx-(j+1))
print(ans)

Measured memory_bytes: 3188
#pragma GCC optimize("O3")
#define first x
#define second y
#include <bits/stdc++.h>

using namespace std;

enum {MOD0 = 1000000000, MOD7 = 1000000007, MOD9 = 1000000009};
typedef unsigned short ushort;typedef unsigned int uint;typedef long long ll;typedef unsigned long long ull;
#ifndef CrafterKolyan
#define endl '\n'
#endif

signed main() {
#ifndef CrafterKolyan
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int n, d;
    cin >> d >> n;
    int rr = 1;
    while (d--) {
        rr *= 100;
    }
    if (n == 100) {
        ++n;
    }
    cout << n * rr << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define vll vector<pair<ll, ll> >
#define vl vector<ll>
#define vi vector<int>
#define vii vector<pair<int, int> >
const ll mod = 1e9 + 7;
using namespace std;

ll power_mod(ll x, ll y, ll p)
{
	ll ans = 1;
	x = x%p;
	if(x==0)
	return p;

	while(y>0)
	{
		if(y&1)
		{
			ans = (ans*x)%p;
		}
		y = y>>1;
		x = (x*x)%p;
	}
	return ans;
} 

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	getline(cin, s);
	while(s.length()==0)
	getline(cin, s);
	
	ll i,j,k,l,m,n;
	ll sum=0;
	for(i=0;i<s.length()/2;i++)
	{
	    if(s[i]!=s[s.length()-1-i])
	    sum++;
	}
	cout<<sum<<"\n";
	return 0;
}


Measured memory_bytes: 3656
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {  

	public static void main(String[] args) {   
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		long A = I.nextLong();
		long B = I.nextLong();
		long ans = 0;
		long[] X = new long[N];
		for (int i = 0; i < N; i++) X[i] = I.nextLong();
		for (int i = 0; i < N-1; i++) {
			long curans = B; //Teleport option
			curans=Math.min(curans, (X[i+1]-X[i])*A);
			ans+=curans;
		}
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 41292
#include <iostream>

using namespace std;

int main()
{
	int n, m , x, y;
	cin >> n >> m >> x >> y;
	for(int i=0;i<n;i++) {
		int t;
		cin >> t;
		x = max(x, t);
	}
	for(int i=0;i<m;i++) {
		int t;
		cin >> t;
		y = min(y, t);
	}
	if(y > x) {
		cout << "No War" << endl;
	} else {
		cout << "War" << endl;
	}
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16]={0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
struct unionFind{
  int M, N, *d;
  inline void malloc(const int n){
    d = (int*)std::malloc(n*sizeof(int));
    M = n;
  }
  inline void free(void){
    std::free(d);
  }
  inline void walloc(const int n, void **mem=&wmem){
    walloc1d(&d, n, mem);
    M = n;
  }
  inline void init(const int n){
    int i;
    N = n;
    for(i=0;i<(n);i++){
      d[i] = -1;
    }
  }
  inline void init(void){
    init(M);
  }
  inline int get(int a){
    int k, t=a;
    while(d[t]>=0){
      t=d[t];
    }
    while(d[a]>=0){
      k=d[a];
      d[a]=t;
      a=k;
    }
    return a;
  }
  inline int connect(int a, int b){
    if(d[a]>=0){
      a=get(a);
    }
    if(d[b]>=0){
      b=get(b);
    }
    if(a==b){
      return 0;
    }
    if(d[a] < d[b]){
      d[a] += d[b];
      d[b] = a;
    }
    else{
      d[b] += d[a];
      d[a] = b;
    }
    return 1;
  }
  inline int operator()(int a){
    return get(a);
  }
  inline int operator()(int a, int b){
    return connect(a,b);
  }
  inline int& operator[](const int a){
    return d[a];
  }
  inline int sizeList(int res[]){
    int i, sz=0;
    for(i=0;i<(N);i++){
      if(d[i]<0){
        res[sz++] = -d[i];
      }
    }
    return sz;
  }
}
;
char memarr[96000000];
int N;
int M;
int P[100000];
int X;
int Y;
int main(){
  int KL2GvlyY, i, res=0;
  unionFind uf;
  wmem = memarr;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(P[Lj4PdHRW]);P[Lj4PdHRW] += (-1);
    }
  }
  uf.malloc(N);
  uf.init(N);
  for(KL2GvlyY=0;KL2GvlyY<(M);KL2GvlyY++){
    rd(X);X += (-1);
    rd(Y);Y += (-1);
    uf(X,Y);
  }
  for(i=0;i<(N);i++){
    if(uf(i)==uf(P[i])){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190902-1

// --- original code ---
// int N, M, P[1d5], X, Y;
// {
//   int res = 0;
//   unionFind uf;
//   rd(N,M,(P--)(N));
//   uf.malloc(N);
//   uf.init(N);
//   rep(M){
//     rd(X--,Y--);
//     uf(X,Y);
//   }
//   rep(i,N) if(uf(i)==uf(P[i])) res++;
//   wt(res);
// }


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<string>
#define LL long long
#define li i<<1
#define ri i<<1|1
using namespace std;
inline LL read()
{
    char c=getchar();LL x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
const int maxn=2e5+5;
LL n,m,k,a[maxn],b[maxn],sum_a[maxn],sum_b[maxn],ans,l,r; 
int main()
{
	n=read();
	m=read();
	k=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
		sum_a[i]=sum_a[i-1]+a[i];
	}	
	for(int i=1;i<=m;++i){
		b[i]=read();
		sum_b[i]=sum_b[i-1]+b[i];
	}
	for(int i=n;i>=1;--i){
		if(sum_a[i]<=k){
			r=i;
			ans=i;
			break;
		}
	}
	for(int i=1;i<=m;){
		if(r<0)
			break;
		if(sum_a[r]+sum_b[i]>k)
			--r;
		else{
			ans=max(ans,i+r);
			++i;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 10004
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf 1000000007
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな

signed main() {
    int n;cin>>n;
    int a[314514];
    int sume[314514]={};
    int sumw[314514]={};
    rep(i,1,n+1){
        char c;
        cin>>c;
        if(c=='W')a[i]=1;
        else a[i]=0;
    }
    rep(i,1,n+1){
        if(a[i]==0){
            sume[i]=sume[i-1]+ 1;
            sumw[i]=sumw[i-1];
        }
        else {
            sume[i]=sume[i-1];
            sumw[i]=sumw[i-1]+1;
        }
    }
    int ans=inf;
    rep(i,1,n+1){
        int k=sumw[i-1]-sumw[0]+sume[n]-sume[i];
        if(i==1)ans=k;
        else ans=min(ans,k);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7680