akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int n,m;
int a[200010];
long long b[200010],c[200010];
long long ans;

int main()
{int i,j,x,y,l,r,p;
 long long s=0;
 
 scanf("%d%d",&n,&m);
 for(i=1;i<=n;i++) scanf("%d",&a[i]);
 for(i=1;i<n;i++)
 {	x=a[i];
 	y=a[i+1];
 	if(x==y || x%m+1==y) continue;
 	if(y>=x)
 		l=y-x;
 	else
 		l=y-x+m;
 	p=(x+2-1)%m+1;
 	if(p<=y)
 	{	b[p]++;
 		if(y!=m) b[y%m+1]--;
 	}
 	else
 	{	b[p]++;
 		b[1]++;
 		c[1]+=m-p+1;
 		if(y!=m) b[y%m+1]--;
 	}
 	if(y!=m) c[y%m+1]-=l-1;
 	//cout<<l<<endl;
 }
 for(i=1;i<=m;i++)
 	b[i]+=b[i-1];
 
 //for(i=1;i<=m;i++) cout<<b[i]<<" ";
 //cout<<endl;
 	
 for(i=1;i<=m;i++)
 	c[i]+=b[i];
 for(i=1;i<=m;i++) c[i]+=c[i-1];	
 	
 //for(i=1;i<=m;i++) cout<<c[i]<<" ";
 //cout<<endl;	
 	
 for(i=1;i<=m;i++) 
	s=max(s,c[i]);
 for(i=1;i<n;i++)
 	if(a[i+1]>=a[i])
	 	ans+=a[i+1]-a[i];
	else
		ans+=a[i+1]-a[i]+m;
 ans-=s;
 printf("%lld\n",ans);
 return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define INF (1LL<<32)
const int maxv=100+10;
const int maxe=9900+10;
int V,E;
long long d[maxv][maxv];

void floyd()
{

    for(int k=0; k<V; k++)
    {
        for(int i=0; i<V; i++)
        {
            if(d[i][k]==INF) continue;
            for(int j=0; j<V; j++)
            {
                if(d[k][j]==INF) continue;
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);

            }
        }
    }
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d%d",&V,&E);
    int u,v,cost;
    for(int i=0; i<V; i++)
    {
        for(int j=0; j<V; j++)
        {
            if(i==j) d[i][j]=0;
            else d[i][j]=INF;

        }
    }
    for(int i=0; i<E; i++)
    {
        scanf("%d%d%d",&u,&v,&cost);
        d[u][v]=cost;

    }
    floyd();
    bool negative=false;
    for(int i=0; i<V; i++)
    {
        if(d[i][i]<0) negative=true;
    }
    if(negative)
    {
        printf("NEGATIVE CYCLE\n");
    }
    else
    {
        for(int i=0; i<V; i++)
        {
            for(int j=0; j<V; j++)
            {
                if(j) printf(" ");
                if(d[i][j]!=INF) printf("%lld",d[i][j]);
                else printf("INF");
            }
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 3308
from collections import deque


H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

INF = 10 ** 6
m = [[10 ** 6] * W for _ in range(H)]
dy = [-1, 1, 0, 0]
dx = [0, 0, -1, 1]


def bfs(y, x):
    q = deque()
    q.append((y, x))

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

        for i in range(4):
            ny = y + dy[i]
            nx = x + dx[i]

            if (0 <= ny < H and 0 <= nx < W and
                m[ny][nx] == INF and S[ny][nx] != '#'):

                q.append((ny, nx))
                m[ny][nx] = m[y][x] + 1

ans = 0
for y in range(H):
    for x in range(W):
        if S[y][x] != "#":
            m = [[10 ** 6] * W for _ in range(H)]
            m[y][x] = 0
            bfs(y, x)
            for i in range(H):
                for j in range(W):
                    if m[i][j] != INF:
                        ans = max(ans, m[i][j])

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl;
#define F first
#define S second
typedef long long ll;
typedef pair<int,char> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  int t;
  cin >> t;
  while(t--) {
    int a[3][10];
    memset(a,0,sizeof(a));
    P b[9];
    rep(i,9) cin >> b[i].F;
    rep(i,9) cin >> b[i].S;
    rep(i,9) {
      if(b[i].S=='R') a[0][b[i].F]++;
      else if(b[i].S=='G') a[1][b[i].F]++;
      else a[2][b[i].F]++;
    }
    int ans=1;
    rep(i,3) {
      rep(j,10) {
	if(a[i][j]) {
	  if(a[i][j]>=3) {
	    a[i][j]-=3;
	    j--;
	  } else if(j<8 && a[i][j] && a[i][j+1] && a[i][j+2]) {
	    a[i][j]--;a[i][j+1]--;a[i][j+2]--;
	    j--;
	  } else ans=0;
	}
      }
    }
    pr(ans);
  }
  return 0;
}


Measured memory_bytes: 1160
object Main extends App {
  val input = io.Source.stdin.getLines.toIndexedSeq.tail
  .map(_.split(' ').map(_.toInt).toIndexedSeq)
  
  val ans = (0 until input(0).size).foldLeft(0){ (acc, i) =>
    val usum = (0 to    i            ).foldLeft(0)( (a,j) => a + input(0)(j) )
    val lsum = (i until input(1).size).foldLeft(0)( (a,j) => a + input(1)(j) )
    val sum = usum + lsum
    Math.max(acc, sum)
  }
  println(ans)
}


Measured memory_bytes: 25424
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>

typedef long long ll;

using namespace std;

int main() {
	
	int a, b;
	char c;
	cin >> a >> c >> b;
	int ans;
	if (c == '+') {
		ans = a + b;
	} else {
		ans = a - b;
	}
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll a, b, n;
	cin >> a >> b >> n;
	ll x;
	if (n >= b) {
		x = b - 1;
	}
	else {
		x = n;
	}
	cout << (a * x) / b - a * (x / b);
}

Measured memory_bytes: 3648
//In the middle of Difficulty, lies Opportunity

#include <bits/stdc++.h>

#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;


void sol(){
	
}

int main(){
    std::ios::sync_with_stdio(false);
    int t = 1;
    cin >> t;
    if (t >= 30)
    	cout << "Yes\n";
    else
    	cout << "No\n";

    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<math.h>
typedef struct{
	double x;
	double y;
}p;
void kock(int,p,p);

int main(){
	int n;
	p a={0.0,0.0};
	p b={100.0,0.0};
	scanf("%d",&n);
	printf("%f %f\n",a.x,a.y);
	kock(n,a,b);
	printf("%f %f\n",b.x,b.y);
	return 0;
}

void kock(int n,p p1,p p2){
	p s,u,t;
	if(n==0)return;
	s.x=(p1.x*2+p2.x)/3;
	t.x=(p1.x+p2.x*2)/3;
	s.y=(p1.y*2+p2.y)/3;
	t.y=(p1.y+p2.y*2)/3;
	u.x=cos(M_PI/3)*(t.x-s.x)-sin(M_PI/3)*(t.y-s.y)+s.x;
	u.y=sin(M_PI/3)*(t.x-s.x)+cos(M_PI/3)*(t.y-s.y)+s.y;
	
	kock(n-1,p1,s);
	printf("%f %f\n",s.x,s.y);
	kock(n-1,s,u);
	printf("%f %f\n",u.x,u.y);
	kock(n-1,u,t);
	printf("%f %f\n",t.x,t.y);
	kock(n-1,t,p2);
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}
 
int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    int ans=0;
    ans += 7 * (C / (7*A+B));

    C %= (7*A+B);
    if(C > 7*A){
        ans += 7;
    }else{
        ans += C/A;
        if(C%A != 0) ans++;
    }

    print(ans);
    return 0;
}


Measured memory_bytes: 3220
#include <iostream>
using namespace std;
int main () {
    int N, M=0, cnt=0, ans=0;
    cin >> N;
    M=N;
    for (ans=0;cnt<2;ans++){
        if (M==4)
            cnt++;
        if (M%2==1)
            M=3*M+1;
        else
            M/=2;
    }
    if (N==1 || N==2)
        ans=4;
    cout << ans;
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<pair<ll, ll>> p(N);
    rep(i, 0, N)
    {
        ll a, b;
        cin >> a >> b;
        p.at(i) = make_pair(b, a);
    }
    sort(all(p));
    ll total = p.at(0).second;
    ll due = p.at(0).first;
    rep(i, 1, N)
    {
        total += p.at(i).second;
        if (p.at(i).first != p.at(i - 1).first)
        {
            due = p.at(i).first;
        }
        if (total > due)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    if (total > p.at(N - 1).first)
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3328
qn  = gets.chomp.to_i
qso = gets.chomp.split(" ").map(&:to_i)
an = gets.chomp.to_i
aso = gets.chomp.split(" ").map(&:to_i)

qsd = Hash.new(0)
qso.each do |q|
  qsd[q] += 1
end

fl = 0
aso.each do |a|
  qsd[a] -= 1
  if qsd[a] < 0
    puts "NO"
    fl += 1
    break
  end
end

if fl < 1
  puts "YES"
end

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

using namespace std;

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
#define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

const ll MOD = 1e9 + 7;
const ll maxn = 2e5 + 5;

void solve(){
	int n;
	cin >> n;
	map<int,int> mp;
	ll sum=0;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		mp[a]++;
		
	}
	for(auto x:mp){
		sum += (x.first)*(x.second);
	}
	int q;
	cin >> q;
	int a,b;
	while(q--){
		cin >> a >> b;
		sum -= 1LL*mp[a]*a;
		sum += 1LL*mp[a]*b;
		mp[b] += mp[a];
		mp[a]=0;
		cout << sum <<'\n';
	}
}

int main() {
    IOS
    
        solve();
    cerr << endl << "[ Time : " << (float) clock() / CLOCKS_PER_SEC << " secs ]" << endl;

}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 8200
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { int A, B;
  cin >> A >> B;
  cout << A * B << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;

template<typename T>
class UnionFind {
public:
  vector<T> data;
  UnionFind(T size) : data(size, -1) {}

  // xの属する木とyの属する木を融合
  bool union_set(T x, T y)
  {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) {
        swap(x, y);
      }
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }

  // x, yが同じ木に属するならtrue, そうでないならfalse
  bool find_set(T x, T y)
  {
    return root(x) == root(y);
  }

  // xの属する木の根を出力
  T root(T x)
  {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }

  // xの属する木に含まれる要素の数を出力
  T size(T x)
  {
    return -data[root(x)];
  }
};

int main(void)
{
  LL N, M;
  cin >> N >> M;

  vector<P> br;
  for (LL i = 0; i < M; i++) {
    P temp;
    cin >> temp.first >> temp.second;
    br.push_back(temp);
  }

  reverse(br.begin(), br.end());

  UnionFind<LL> uft(N);
  LL *ans = new LL[M];
  ans[M - 1] = N*(N - 1) / 2;
  LL index = M - 2;

  for (auto itr = br.begin(); itr != br.end(); ++itr, --index) {
    if (index < 0) break;

    if (!uft.find_set(itr->first - 1, itr->second - 1)) {
      ans[index] = ans[index + 1] - uft.size(itr->first - 1)*uft.size(itr->second - 1);
      uft.union_set(itr->first - 1, itr->second - 1);
    }
    else {
      ans[index] = ans[index + 1];
    }
  }

  for (LL i = 0; i < M; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 4464
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int a[]= new int[N];
		double b[] = new double[N];
		int max=0;
		int sum =0;
		for (int i=0;i<N;i++) {
			a[i] = sc.nextInt();
		}
		for (int i=0;i<K;i++) {
			max+=a[i];
		}
		sum =max;
		for (int i=K;i<N;i++) {
			sum = a[i]+sum-a[i-K];
			if (sum >max) {
				max = sum;
			}
		}
		double d = max+K;
		System.out.println(d/(double)2);
	}
}


Measured memory_bytes: 74844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    ll a, b, n; cin >> a >> b >> n;
    if (n >= b) cout << (a*(b-1))/b - a*((b-1)/b) << endl;
    else cout << (a*n)/b - a*(n/b) << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main(){
  int n;
  scanf("%d", &n);
  int t[n],x[n],y[n];
  for(int i=0;i<n;i++){
    scanf("%d %d %d",&t[i],&x[i],&y[i]);
  }
  if(abs(x[0])+abs(y[0])>t[0] || (abs(x[0])+abs(y[0]))%2!=t[0]%2){
    printf("No\n");
    return 0;
  }
  for(int i=1;i<n;i++){
    if(abs(x[i]-x[i-1])+abs(y[i]-y[i-1])>t[i]-t[i-1]||(abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2!=(t[i]-t[i-1])%2){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> order(n);

    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        order[i] = i;
    }

    double sum = 0.0;
    double p = 0.0;

    do{
        for(int i = 1; i < n; i++){
            int xx = x[order[i]]-x[order[i-1]];
            int yy = y[order[i]]-y[order[i-1]];
            double t = xx*xx;
            t += yy*yy;
            sum += sqrt(t);
        }
        p += 1.0;
    }while(next_permutation(order.begin(), order.end()));

    cout << std::fixed << std::setprecision(8) << sum/p << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b;
            
            string[] str = Console.ReadLine(). Split(' ');　//二つ以上のすぺーすくぎりを使う
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            if (a <= b * 2)
                Console.WriteLine(0);
            else
                Console.WriteLine(a - b * 2);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11220
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int Y = sc.nextInt();
	
    int resA = -1, resB = -1, resC = -1;
	int tmpMoney = 0;
	boolean isTruth = false;
	
	for (int a=0; a<=N; a++){
	  for (int b=0; b<=N-a; b++){
	    int c = N - a - b;
	    tmpMoney = 10000*a + 5000*b + 1000*c;
	    if(tmpMoney == Y){
	      resA = a;
          resB = b;
          resC = c;
          isTruth = true;
	      break;
	    }
	  }
      if(isTruth)
        break;
	}
	
	System.out.println(resA + " " + resB + " " + resC);
  }
}

Measured memory_bytes: 23764
money_count, target_sum = map(int, input().split())

is_find = False

for yukichi_count in range(money_count + 1):
	for higuchi_count in range(money_count + 1 - yukichi_count):
		noguchi_count = money_count - yukichi_count - higuchi_count
		money_sum = yukichi_count * 10000 + higuchi_count * 5000 + noguchi_count * 1000
		if money_sum == target_sum:
			print(yukichi_count, higuchi_count, noguchi_count)
			is_find = True
			break
	if is_find:
		break

if not is_find:
	print('-1 -1 -1')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define nl printf("\n")
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
using namespace std;
int p[100002][4];
int a[100002][4];
int max_sum(int c,int i,int n){
    if(c>n) return 0;
    if(p[c][i]!=-1) return p[c][i];
    int j;
    int mx=0;
    for(j=0;j<3;j++){
        if(j==i) continue;
        mx=max(mx,a[c][j]+max_sum(c+1,j,n));
    }
    return p[c][i]=mx;
}
main()
{
    int n,ans;
    scanf("%d",&n);
    int i;
    for(i=1;i<=n;i++){
        scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
        p[i][0]=-1;
        p[i][1]=-1;
        p[i][2]=-1;
        p[i][3]=-1;

    }
    ans=max_sum(1,3,n);
    printf("%d\n",ans);
}


Measured memory_bytes: 14648
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
int x[110000];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++){
		scanf("%d",x+i);
	}
	long long ret=0;
	for(int i=0;i<a-1;i++){
		int d=x[i+1]-x[i];
		ret+=min((long long)c,(long long)b*d);
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 640
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    }
    println!("{}",((a+1)/2)*(a/2))
}

Measured memory_bytes: 2108
import collections
N = int(input())
S = input()
ans = 0
for i in range(1, N):
    left = S[:i]
    right = S[i:]
    count_left = collections.Counter(left)
    count_right = collections.Counter(right)
    count_left_unique = list(count_left.keys())
    count_right_unique = count_right.keys()
    cnt = 0
    for j in range(len(count_left_unique)):
        if(count_left_unique[j] in count_right_unique):
            cnt += 1
    ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define INF 2147483647
#define ll long long
#define asort(a) sort(a.begin(),a.end());//昇順ソート
#define usort(a) sort(a.rbegin(),a.rend());//降順ソート

using namespace::std;

int jo(ll int a, ll int b){//累乗
    ll int num=1;
    rep(i,0,b) num=num*a;
    return num;
}
char tobig(char s){//char大文字化
  return (s-0x20);
}
char tolow(char s){//char小文字化
  return (s+0x20);
}
int ctoi(char a){//char->int
  if('0'<=a&&a<='9') return (a-'0');
  return -1;
}

int gcd(ll int a,ll int b) {//最大公約数
  if(a<b) return gcd(b,a);
  int c;
  while ((c=a%b)) {
    a=b;
    b=c;
  }
  return b;
}
int lcm(ll int a,ll int b){//最小公倍数
 return (a*b)/gcd(a,b);
}


int act(int num){
  num=floor((double(jo(num,2))+4.0)/8.0);
  return num;
}

int main(){
  int N,K;
  cin>>N>>K;
  vector<string> S(N);
  rep(i,0,N) cin>>S[i];
  asort(S);
  rep(i,0,N) cout<<S[i];
}




// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示

//  vector<pair<int,int>> data(N);  //2つのデータを格納、.first/.secondで参照
// pairのソートはfirst優先の昇順


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sc1(n) scanf("%lld",&n)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define MX 100000
using namespace std;

typedef long long int ll;
typedef unsigned long long ul;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll arr[100005];
ll dp[100005];
ll n;
ll solve(ll pos)
{
    if(pos>=n)
    {
        return 0;
    }
    if(dp[pos]!=-1)
        return dp[pos];
    ll ret1=0,ret2=0;
    ret1=abs(arr[pos]-arr[pos+1])+solve(pos+1);
    ret2=abs(arr[pos]-arr[pos+2])+solve(pos+2);

    return dp[pos]=min(ret1,ret2);

}
int main()
{
    memset(dp,-1,sizeof dp);
    sc1(n);
    for(ll i=1;i<=n;i++)
    {
        sc1(arr[i]);
    }
    arr[n+1]=INT_MAX;
    arr[n+2]=INT_MAX;
    ll ans=solve(1);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
using namespace std;

const char person[] = {'J', 'C', 'E', 'A', 'P', 'M'};

vector<char> decode(const vector<char>& messangers, const vector<char>& message){
  vector<char> ans;

  for(int i=0;i<message.size();++i){
    ans.push_back(message[i]);
  }

  for(int i=messangers.size()-1;i>=0;--i){
    if(messangers[i]==person[0]){
      for(int j=ans.size()-1;j>0;--j){
        swap(ans[j],ans[j-1]);
      }
    }else if(messangers[i]==person[1]){
      for(int j=0;j<ans.size()-1;++j){
        swap(ans[j],ans[j+1]);
      }
    }else if(messangers[i]==person[2]){
      for(int j=0,k;j<ans.size()/2;++j){
        ans.size()%2==1 ? k=ans.size()/2+1 : k=ans.size()/2;
        swap(ans[j],ans[j+k]);
      }
    }else if(messangers[i]==person[3]){
      reverse(ans.begin(), ans.end());
    }else if(messangers[i]==person[4]){
      for(int j=0;j<ans.size();++j){
        if(isdigit(ans[j])){
          if(ans[j]=='0') ans[j]='9';
          else --ans[j];
        }
      }
    }else if(messangers[i]==person[5]){
      for(int j=0;j<ans.size();++j){
        if(isdigit(ans[j])){
          if(ans[j]=='9') ans[j]='0';
          else ++ans[j];
        }
      }
    }
  }

  return ans;
}

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

  for(int index=0;index<n;++index){
    vector<char> messangers,message;
    string tmp;

    cin>>tmp;
    for(int i=0;i<tmp.size();++i)
      messangers.push_back(tmp.at(i));

    cin>>tmp;
    for(int i=0;i<tmp.size();++i)
      message.push_back(tmp.at(i));

    vector<char> ans;
    ans = decode(messangers, message);

    for(int i=0;i<ans.size();++i)
      cout << ans.at(i);
    
    cout << endl;
  }

  return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
    cout << "Left" << endl;
  } else if (A + B < C + D) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }  
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[310000];
long long sum[310000];
long long res[310000];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",b+i);
	}
	std::sort(b,b+a);
	for(int i=0;i<a;i++)sum[i]=b[i];
	for(int i=1;i<a;i++)sum[i]+=sum[i-1];
	int c;
	scanf("%d",&c);
	for(int i=0;i<c;i++){
		int p;scanf("%d",&p);
		int t=upper_bound(b,b+a,p)-b-1;
		if(t>=0)res[i]=sum[t];
	}
	for(int i=0;i<c;i++){
		long long p;scanf("%lld",&p);
		if(res[i]>=p)printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 6824
#include<iostream>
#include<queue>
#define N 3
#define MAX 16
using namespace std;

double posib[N][N][MAX];
static const int di[] = {-1,0,1,0};
static const int dj[] = {0,1,0,-1};

bool isinside( int i, int j ){
  return 0<=i&&i<N && 0<=j&&j<N;
}

int main()
{
  while(true){
    int n;
    char s,t,b;
    int si,sj,ti,tj,bi,bj;

    cin >> n >> s >> t >> b;
    if( n == 0 ) break;
    // cout << s << ' ' << t << ' ' << b << endl;
    s -= 'A'; t -= 'A'; b -= 'A';
    si = s / N; sj = s % N;
    ti = t / N; tj = t % N;
    bi = b / N; bj = b % N;

    for(int i = 0; i < N; ++i){
      for(int j = 0; j < N; ++j){
	for(int k = 0; k < MAX; ++k){
	  posib[i][j][k] = 0.0;
	}
      }
    }
    posib[ti][tj][0] = 1.0;
    posib[bi][bj][0] = 0.0;

    for(int k = 1; k < MAX; ++k){
      //cout << "K = " << k << endl;
      for(int i = 0; i < N; ++i){
	for(int j = 0; j < N; ++j){

	  if( i == bi && j == bj ) continue;

	  int cnt = 4;

	  for(int l = 0; l < sizeof(di)/sizeof(*di); ++l){
	    int li = i+di[l];
	    int lj = j+dj[l];

	    if( li == bi && lj == bj || !isinside( li, lj ) ){
	      posib[i][j][k] += posib[i][j][k-1] / (double)cnt;
	    }else if( isinside( li, lj ) ){
	      posib[i][j][k] += posib[li][lj][k-1] / (double)cnt;
	    }

	  }
	  
	  //cout << posib[i][j][k] << "(CNT:"<<cnt<<") ";
	}
	//cout << endl;
      }
      //cout << endl;
    }
    printf("%.6lf\n", posib[si][sj][n]);
    //return 0;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
#include <string.h>
using namespace std;

#define N 502
#define M 1000000
int A[N],tmp[N];
int dv[M];
void solve() {
  int n,k;scanf("%d %d ",&n,&k);
  int sum = 0,pos=0;
  for(int i=1;i<=n;++i) scanf("%d ", &A[i]),sum += A[i];

  for(int i=1;i*i<=sum;++i) {
    if(sum%i==0) {
      dv[pos++] = i;
      if(i*i!=sum) {
        dv[pos++] = sum/i;
      }
    }
  }
  sort(dv,dv+pos);
  for(int i=pos-1;i;--i) {
    int val = dv[i], len = 0,u;
    long long tmpSum = 0;
    for(int j = n;j;--j) {
      if(A[j]%val==0) continue;
      u= val - (A[j]%val);
      tmpSum += u;
      tmp[len++] = val - u;
    }
    long long minValue = 0;
    if(len>0) {
      sort(tmp,tmp+len);
      long long need = tmpSum/val;
      for(int j=0;j<need;++j) {
        minValue += tmp[j];
      }
    }
    if(minValue<=k) {
      printf("%d\n", val);
      return;
    }
  }
  printf("1\n");
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


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

using namespace std;

int main()
{
    int a, b, t;
    scanf("%d %d %d",&a, &b, &t);
    int res = 0, i = 1;;
        t += 0.5;
         while((i * a) <= t){
            res += b;
            i++;
         }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 3804
import java.util.*;



class Main{

    public static void main(String[] args){

	int gyo,retu,n;
	String sc;
	Scanner in = new Scanner(System.in);


	gyo = in.nextInt();
	retu = in.nextInt();
	n = in.nextInt();
	int[][] jm = new int[gyo+1][retu+1];
	int[][] om = new int[gyo+1][retu+1];
	int[][] im = new int[gyo+1][retu+1];
	for(int i=0;i<=gyo;i++){
	    for(int j=0;j<=retu;j++){
		jm[i][j]=0;
		om[i][j]=0;
		im[i][j]=0;
	    }
	}

	//Arrays.fill(jm,0); //memsetÂIÂÃÂÂ¨ÂÂ©memÂÃÂÃÂÃ¡ÂÃÂÃ2ÂÂÂÂ¾ÂÃÂGÂÂÂ[ÂÂ©ÂÃÂÃ§ÂÂ½ÂgÂÂ¦ÂÃÂÂ¢ÂÂ¢ÂÃÂHÂÂ©ÂmÂÃ§ÂÃÂÂ¢ÂÂ©ÂÃ§ÂÂÂÃÂÃÂÂÂ[ÂvÂÃ±ÂÂ·
	//Arrays.fill(om,0);
	//Arrays.fill(im,0);

	for(int i=1;i<=gyo;i++){
	    sc = in.next();
	    for(int j=0;j<retu;j++){
		char cc[] = sc.toCharArray();
		jm[i][j+1]=jm[i-1][j+1]+jm[i][j]-jm[i-1][j];
		om[i][j+1] = om[i-1][j+1]+om[i][j]-om[i-1][j];
		im[i][j+1]=im[i-1][j+1]+im[i][j]-im[i-1][j];
		if(cc[j] == 'J'){
		    jm[i][j+1]++;
		}else if(cc[j] == 'O'){
		    om[i][j+1]++;
		}else if(cc[j] == 'I'){
		    im[i][j+1]++;
		}


	    }
	}

	/*	
		for(int i=0;i<=gyo;i++){
		for(int j=0;j<=retu;j++)System.out.print(jm[i][j] + " ");
		System.out.printf("\n");
		}
	*/
	
	int a,b,c,d;
	for(int i=0;i<n;i++){
	    a = in.nextInt();
	    b = in.nextInt();
	    c = in.nextInt();
	    d = in.nextInt();
	    System.out.print(jm[c][d]-jm[a-1][d]-jm[c][b-1]+jm[a-1][b-1]);
	    System.out.print(" ");
	    System.out.print(om[c][d]-om[a-1][d]-om[c][b-1]+om[a-1][b-1]);
	    System.out.print(" ");
	    System.out.println(im[c][d]-im[a-1][d]-im[c][b-1]+im[a-1][b-1]);

	}
	


    }


}

Measured memory_bytes: 24000
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int N = 1e5+10;
int a[N],b[N],c[N];

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

  int n; cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i] >> c[i];
  }

  vector< vector<int> > dp(3,vector<int>(N,0));
  for(int i = 0; i < n; i++){
    dp[1][i+1] = max(dp[1][i+1],dp[0][i] + b[i]);
    dp[2][i+1] = max(dp[2][i+1],dp[0][i] + c[i]);

    dp[0][i+1] = max(dp[0][i+1],dp[1][i] + a[i]);
    dp[2][i+1] = max(dp[2][i+1],dp[1][i] + c[i]);

    dp[0][i+1] = max(dp[0][i+1],dp[2][i] + a[i]);
    dp[1][i+1] = max(dp[1][i+1],dp[2][i] + b[i]);
  }
  cout << max(dp[0][n],max(dp[1][n],dp[2][n])) << endl;

  return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#define INF -10000000000000000;
using namespace std;

long long int num[100100];


int main(){
    long long int n,m;
    long long int sum=0;
    long long int ans=INF;
    while(1){
        cin>>n>>m;
        if(n==0&&m==0)break;
        for(int i=0;i<100100;i++){
            num[i]=0;
            if(num[i+1]==0)break;
        }
        for(int i=0;i<n;i++){
            cin>>num[i];
            if(i<m)sum+=num[i];
        }
      //  cout<<sum<<endl;
        for(int i=1;i<n-m;i++){
            sum=sum-num[i-1]+num[i+m-1];
          //  cout<<sum<<endl;
            if(ans<sum)ans=sum;
        }
        cout<<ans<<endl;
        ans=INF;
        sum=0;
        }
    return 0;
}

Measured memory_bytes: 1936
#include <iostream>
#include <math.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

bool prime[100001] = {};
bool likeprime[100001] = {};
ll s[100001] = {};
int main() {
	rep(i, 0, 100001)prime[i] = true;
	prime[0] = false;
	prime[1] = false;
	repe(i, 2, sqrt(100001)) {
		if (prime[i]) {
			ll b = 2;
			while (i*b < 100001) {
				prime[i*b] = false;
				b++;
			}
		}
	}
	rep(i, 0, 100001) likeprime[i] = prime[i];
	rep(i, 0, 100001) {
		if (prime[i]) {
			if (!prime[(i + 1) / 2]) {
				likeprime[i] = false;
			}
		}
	}
	rep(i, 2, 100001) {
		s[i] = likeprime[i] + s[i - 1];
	}

	ll q; cin >> q;
	rep(i, 0, q) {
		ll a, b; cin >> a >> b;
		cout << s[b] - s[a - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,w,n,x,y,cnt=0;
	cin>>h;
	cin>>w;
	cin>>n;
	x=min(h,w);
	y=max(h,w);
	while(n>=x){
		n-=y;
		cnt++;
	}
	if(n<=0) cout<<cnt<<endl;
	else cout<<cnt+1<<endl;
	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void ChMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void ChMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  DivUp(T a, T b)   {return ((a+b-1)/b);}

int main(){
    int a; cin  >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}
/*

*/


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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define vi vector<int>

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}

int main() {
int N;
string s;
cin>>N>>s;
int index = s.find("ABC");
int c = 0;
while(index!=-1) {
    c++;
    index = s.find("ABC",index+1);
}
cout<<c<<endl;
return 0;
}


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

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ABC = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (A, B, C) = (ABC[0], ABC[1], ABC[2]);
            var K = int.Parse(Console.ReadLine());

            for (var i = 0; i < K; i++)
            {
                if (B <= A) B *= 2;
                else if (C <= B) C *= 2;
            }

            var answer = A < B && B < C;
            Console.WriteLine(answer ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 28224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();


		boolean a=(1+(K-1)*2<=N);
		System.out.println(a?"YES":"NO");

	}

}


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

using namespace std;

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

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

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

struct UnionFind {
    UnionFind(int n) {
        rank.assign(n, 0);
        parent.resize(n);
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
    }

    int find(int x) {
        if (x == parent[x])
            return x;
        return parent[x] = find(parent[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    void unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;

        if (rank[x] < rank[y]) {
            parent[x] = y;
        }
        else {
            parent[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }

    vector<int> rank;
    vector<int> parent;
};

int main() {
    ll N, Q;
    cin >> N >> Q;
    UnionFind uf(N);
    REP(i, Q) {
        ll p, a, b;
        cin >> p >> a >> b;
        if (p == 0)
            uf.unit(a, b);
        else {
            if (uf.same(a, b))
                cout << 1 << endl;
            else
                cout << 0 << endl;
        }
    }
    return 0;
}


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

using namespace std;

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

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

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

ll A[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    ll s = 0;
    ll ans = 0;
    REP(i, N) {
        ans += A[i] * s % MOD;
        ans %= MOD;
        s = (s + A[i]) % MOD;
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  bool ok = A[0] == 0 ? true : false;
  ll res = 0;
  for (int i = 1; i < N; i++) {
    if (A[i] == A[i - 1] + 1)
      res++;
    else
      res += A[i];

    if (A[i] - A[i - 1] > 1) {
      ok = false;
    }
  }
  cout << (ok ? res : -1) << '\n';
  return 0;
}


Measured memory_bytes: 1024
class UnionFind:
    __slots__ = ["_data_size", "_roots"]

    def __init__(self, data_size: int) -> None:
        self._data_size = data_size
        self._roots = [-1] * data_size

    def __getitem__(self, x: int) -> int:
        while self._roots[x] >= 0:
            x = self._roots[x]
        return x

    def is_connected(self, x: int, y: int) -> bool:
        return self[x] == self[y]

    def unite(self, x: int, y: int) -> None:
        x, y = self[x], self[y]
        if x == y:
            return
        if self._roots[x] > self._roots[y]:
            x, y = y, x
        self._roots[x] += self._roots[y]
        self._roots[y] = x


def main():
    import sys

    readline = sys.stdin.readline

    N, Q = map(int, readline().split())
    tree = UnionFind(N)
    res = []
    for _ in range(Q):
        t, u, v = map(int, readline().split())
        if t:
            res.append(int(tree.is_connected(u, v)))
        else:
            tree.unite(u, v)
    print("\n".join(map(str, res)))


if __name__ == "__main__":
    main()


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

using lint = long long;
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  lint n;
  cin >> n;

  int sum = 0;
  for (lint i = 0; i < n; i++) {
    int x;
    cin >> x;

    sum += x - 1;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
# from pprint import pprint
# import math
import collections

n = int(input())
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))
s = []
for i in range(n):
    s.append(input())

c = collections.Counter
ans = c(s)

case = ['AC', 'WA', 'TLE', 'RE']

for c in case:
    if c in ans.keys():
        res = ans[c]
    else:
        res = 0
    print(c, 'x', res)


Measured memory_bytes: 16616
X,Y = map(int,input().split())
Z = int(400000)

if X == 1:
	A = 300000
elif X == 2:
	A = 200000
elif X == 3:
  	A = 100000
else:
  	A = 0

if Y == 1:
	B = 300000
elif Y == 2:
	B = 200000
elif Y == 3:
  	B = 100000
else:
  	B = 0
    
if X + Y == 2:
	print(A + B + Z)
else:
  	print(A + B)
  

Measured memory_bytes: 3060
X = int(input())
ans = 0
if X >= 1800:
    ans = 1
elif X >= 1600:
    ans = 2
elif X >= 1400:
    ans = 3
elif X >= 1200:
    ans = 4
elif X >= 1000:
    ans = 5
elif X >= 800:
    ans = 6
elif X >= 600:
    ans = 7
elif X >= 400:
    ans = 8
print(ans)


Measured memory_bytes: 61928
from bisect import bisect_left
n = int(input())
L = list(map(int, input().split()))
L.sort()

cnt = 0
for a in range(n-2):
    for b in range(a+1, n-1):
        cnt += bisect_left(L,L[a]+L[b])-(b+1)
print(cnt)

Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b) { return a < b ? a : b; }

int main(void){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d",  &n, &q);
  for (int i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;

  while (head != tail){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if ( u.t > 0 ) enqueue(u);
    else {
      printf("%s %d\n", u.name, elaps);
    }
  }
  return (0);
}



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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define ul unsigned long long

int main() {
        int N,Q,buf;
        ll count[100001]={};
        ll sum=0;
        cin >> N;
        rep(i,N){
                cin >> buf;
                count[buf]++;
                sum += buf;
        }
        cin >> Q;
        int b[Q]={};
        int c[Q]={};
        rep(i,Q) cin >> b[i] >> c[i];

        //cout << "sum:" << sum << endl;

        rep(i,Q){
                //cout << i << ":" <<b[i] <<"->" << c[i] << endl;
                //cout << "count[b]:" << count[b[i]] << ",count[c]" << count[c[i]]<<endl;
                sum += count[b[i]]*(c[i]-b[i]);
                count[c[i]] += count[b[i]];
                count[b[i]] =0;
            cout <<sum << endl;
        }



}

Measured memory_bytes: 5152
import collections

N = int(input())
A = list(map(int, input().split()))
# sort_A = sorted(A)

C = collections.Counter(A)

s_all = 0
for c in C:
    s_all += C[c] * (C[c] - 1) // 2

for a in A:
    s = 0
    s += s_all - (C[a] - 1)
    print(s)


Measured memory_bytes: 88012
nums = list(map(int, input().split()))
N, M = nums[0], nums[1]
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]

for i in range(N):
    nums = list(map(int, input().split()))
    A[i], B[i] = nums[0], nums[1]

import numpy as np
inds = np.argsort(A)
ans = 0
rem = M
i = 0
while rem > 0:
    num = min(B[inds[i]], rem)
    ans += A[inds[i]] * num
    rem -= num
    i += 1

print(ans)



Measured memory_bytes: 21936
n = gets.chop.to_i
arr = gets.split.map
res = [0, 0, 0, 0]
cnt = 0
arr.each do |c|
  if c == 'P' && res[0] == 0
    cnt += 1
    res[0] = 1
  elsif c == 'W' && res[1] == 0
    cnt += 1
    res[1] = 1
  elsif c == 'G' && res[2] == 0
    cnt += 1
    res[2] = 1
  elsif c == 'Y' && res[3] == 0
    cnt += 1
    res[3] = 1
  end
end
puts cnt == 3 ? 'Three' : 'Four'

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int W, H;
int memo[21][21];
int dfs(int x, int y, int i){
  if(y == H)
	return 1;
  if(x == W)
	return dfs(0, y+1, i);

  if(memo[y][x])
	return dfs(x+1, y, i);

  int res = 0;
  if(x+1 < W && !memo[y][x+1]){
	if(!(y > 0 && x > 0 && memo[y-1][x-1] != memo[y-1][x] && memo[y-1][x-1] != memo[y][x-1])){
	  memo[y][x] = memo[y][x+1] = i;
	  res += dfs(x+1, y, i+1);
	  memo[y][x] = memo[y][x+1] = 0;
	}
  }
  if(y+1 < H && !memo[y+1][x]){
	if(!(y > 0 && x > 0 && memo[y-1][x-1] != memo[y-1][x] && memo[y-1][x-1] != memo[y][x-1])){
	  memo[y][x] = memo[y+1][x] = i;
	  res += dfs(x+1, y, i+1);
	  memo[y][x] = memo[y+1][x] = 0;
	}
  }
  return res;
}

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

  while(cin>>W>>H,W){
	cout << dfs(0,0,1) << endl;
  }

  return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define fastIO  ios_base::sync_with_stdio(false); cin.tie(0); 
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

int main(int argc, char* argv[])
{
	Iint(n);
	int t = 0, x = 0, y = 0;
	for (int i = 0; i < n; ++i)
	{
		int t1, x1, y1;
		scanf("%d %d %d", &t1, &x1, &y1);
		int dis = abs(x1 - x) + abs(y1 - y);
		if(dis>t1-t || (dis-t1 + t)&1 ){ std::cout << "No"; return 0;}
		t = t1, x = x1, y = y1;

	}

	std::cout << "Yes";
}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

using namespace std;

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

int main(){
    int n;
    cin >> n;
    vector<lint> a(n*3);
    rep(i, n*3){
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    lint ans = 0;
    for(int i = 1 ; i < n*2 ; i += 2){
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  string w,t;
  cin >> w ;
  int n=0;

  while(1){
    cin >> t;
    if(t=="END_OF_TEXT")
      break;

    transform(t.begin(),t.end(),t.begin(),::tolower);
    if(w == t)
      n++;
  }

  cout << n << endl;
  return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;

int main() {
    int N; cin >> N;
    vector<P> a(N);
    for (int i = 0; i < N; i++) {
        int x; cin >> x;
        a[i].first = x;
        a[i].second = i;
    }

    sort(a.begin(), a.end());
    int mi = a[0].first;
    int imi = a[0].second;
    
    sort(a.begin(), a.end(), greater<P>());
    int ma = a[0].first;
    int ima = a[0].second;
    
    vector<P> vec;
    
    if (abs(ma) > abs(mi)) {
        for (int i = 0; i < N; i++) {
            if (i == ima) continue;
            a[i].first += ma;
            vec.push_back(P(ima, i));
        }
        for (int i = 1; i < N; i++) {
            a[i].first += a[i-1].first;
            vec.push_back(P(i-1, i));
        }
    }
    else {
        for (int i = 0; i < N; i++) {
            if (i == imi) continue;
            a[i].first += mi;
            vec.push_back(P(imi, i));
        }
        for (int i = N-1; i > 0; i--) {
            a[i-1].first += a[i].first;
            vec.push_back(P(i, i-1));
        }
    }
    
    cout << vec.size() << endl;
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i].first+1 << " " << vec[i].second+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i, j;
	int t;
	int max,z;
	scanf("%d %d %d", &i, &j, &t);
	max = j - i + 1;
	if (max <= 2 * t)
	{
		for (z = i; z<= j; z++)
		{
			printf("%d", z);
			if (z != j)printf("\n");
		}
	}
	else
	{
		for (z = i; z < i + t; z++)
		{
			printf("%d\n", z);
		}
		for (z = j-t+1; z <= j; z++)
		{
			printf("%d", z);
			if (z != j)printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Linq;
class Program
{
    public static void Main()
    {
        //int n = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        int a, b, c;
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);
        c = int.Parse(str[2]);
        if (a + b >= c)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}

Measured memory_bytes: 11092