akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Program
{
    #region Standard I/O
    readonly TextReader input;
    readonly TextWriter output;

    X[] ReadLine<X>(Func<string, X> func)
    {
        return input.ReadLine().Split(' ').Select(func).ToArray();
    }

    void WriteLineOne(object obj)
    {
        output.WriteLine("{0}", obj);
    }

    void WriteLineMany(params object[] objects)
    {
        output.WriteLine(string.Join(" ", objects.Select(obj => obj.ToString())));
    }
    #endregion

    int n;
    int[] js;

    void Read()
    {
        var l = ReadLine(int.Parse);
        n = l[0];
        js = Enumerable.Range(0, n).Select(_ => int.Parse(input.ReadLine()) - 1).ToArray();
    }

    int Solve()
    {
        var done = new bool[n];

        var i = 0;
        var d = 1;

        while (true)
        {
            if (done[i]) return -1;
            done[i] = true;

            var j = js[i];
            if (j == 1) return d;

            i = j;
            d++;
        }
    }

    public void Run()
    {
        Read();
        WriteLineOne(Solve());
    }

    public Program(TextReader input, TextWriter output)
    {
        this.input = input;
        this.output = output;
    }

    public static void Main(string[] args)
    {
        new Program(Console.In, Console.Out).Run();
    }
}


Measured memory_bytes: 16736
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		boolean flag=true;
		for(int i=0; i<N;i++) {
			int x= sc.nextInt();
			if(x%2==0&&x%3!=0&&x%5!=0) {
				flag = false;
			}
				
		}
		
		if(flag) {
			System.out.println("APPROVED");
		}else {
			System.out.println("DENIED");
		}
	}

}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(6 <= a && a <= 12) cout << b/2 << endl;
  else if(a <= 5) cout << 0 << endl;
  else cout << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define R register
#define Min(_A, _B) (_A < _B ? _A : _B)
int N, A, B, Sta[300010], tot;
int main()
{
	scanf("%d %d %d", &N, &A, &B);
	if(A + B - 1 > N) 
	{
		puts("-1");
		return 0;
	}
	/*if(A + B == N + 1)
	{
		for(R int i = B; i; i--) printf("%d ", i);
		for(R int i = B + 1; i <= N; i++) printf("%d ", i);
		return 0;
	}*/
	if(A >= B)
	{
		tot = 0;
		R int a = A, b = B, n = N, v = 0;
		for(R int i = b; i > v; i--, n--) Sta[++tot] = i; a--; v = b;
		while(a)
		{
			R int t = n - a;
			R int uuu = Min(b - 1, t) + 1;
			for(R int i = v + uuu; i > v; i--, n--) Sta[++tot] = i; 
			v += uuu;
			a--;
		}
		if(tot == N)
		{
			for(R int i = 1; i <= tot; i++) printf("%d ", Sta[i]);
			return 0;
		}
	}
	if(A < B)
	{
		tot = 0;
		R int a = B, b = A, n = N, v = 0;
		for(R int i = b; i > v; i--, n--) Sta[++tot] = i; a--; v = b;
		while(a)
		{
			R int t = n - a;
			R int uuu = Min(b - 1, t) + 1;
			for(R int i = v + uuu; i > v; i--, n--) Sta[++tot] = i; 
			v += uuu;
			a--;
		}
		if(tot == N)
		{
			for(R int i = tot; i; i--) printf("%d ", Sta[i]);
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
	string a;
	cin>>a;
	int num=0;
	int l=a.length();
	for(int i=1;i<l;i++){
		if(a[i]!=a[i-1]) num++;
	}
	printf("%d",num);
	return 0;
}

Measured memory_bytes: 512
//#pragma GCC optimize(3)
//#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

#define int long long
int n;
int a[100010];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	int ans=a[0]/2,f=a[0]%2;
	for(int i=1;i<n;i++){
		if(f&&a[i]){
			a[i]--;
			ans++;
		}
		ans+=a[i]/2;
		f=a[i]%2;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
int check(long long int a,long long int b)
{
  int s1=0,s2=0;
  while(a!=0)
  {
    s1++;
    a/=10;
  }
  
  while(b!=0)
  {
    s2++;
    b/=10;
  }
  
  if(s1>=s2)
      return s1;
  
  else
      return s2;
}
  

int main()
{
  long long int n;
  scanf("%lld",&n);
  long int i;
  int min=20;
  for(i=1;i<=sqrt(n);++i)
  {
    if(n%i==0)
    {
      if(min>check(i,n/i))
          min=check(i,n/i);
    }
  }
  printf("%d",min);
}

Measured memory_bytes: 256
x, k, d = map(int, input().split())
x = abs(x)

t = float(abs(x/d))

 
if t >= k:
    print(abs(x - (k*d)))
    
elif (k-int(t))%2==0:
    print(abs(x-abs(int(t)*d)))
    
else:
    print(abs(x-abs(int(t)*d)-d))

Measured memory_bytes: 9200
#include <algorithm>
#include <iostream>
#include <tuple>


int main() {
  int n;
  std::cin >> n;
  int a, b, c;
  std::cin >> a >> b >> c;
  int bestA = a, bestB = b, bestC = c;
  for(int i = 1; i < n; i++) {
    std::cin >> a >> b >> c;
    std::tie(bestA, bestB, bestC) = std::make_tuple(std::max(bestB + a, bestC + a),
                                                    std::max(bestA + b, bestC + b),
                                                    std::max(bestA + c, bestB + c));
  }
  std::cout << std::max(bestA, std::max(bestB, bestC)) << "\n";
}


Measured memory_bytes: 3636
#include<stdio.h>
int main() {
    int n, i ;
    long long ans = 0, c, x[100001], v[100001], p[100001][2], max[100001][2], k, sum[100001][2];
    scanf("%d%ld", &n, &c);
    for (i = 0; i < n; i++) {
        scanf("%ld%ld", &x[i], &v[i]);
    }
    for (i = 0; i < n; i++) {
        if (i == 0)
            sum[0][0] = v[0];
        else
            sum[i][0] = sum[i - 1][0] + v[i];
    }
    for (i = n - 1; i>= 0; i--) {
        if (i == n - 1)
            sum[i][1] = v[i];
        else
            sum[i][1] = sum[i + 1][1] + v[i];
    }
    for (i = 0; i < n; i++) {
        p[i][0]= sum[i][0] - x[i];
        if (i == 0)
            max[i][0] = p[i][0];
        else if (p[i][0] > max[i - 1][0])
            max[i][0] = p[i][0];
        else
            max[i][0] = max[i - 1][0];
        p[i][1]= sum[i][1] - c + x[i];
        if (p[i][0] > ans)
            ans = p[i][0];
        if (p[i][1] > ans)
            ans = p[i][1];
    }
    for (i = n - 1; i >= 0; i--) {
        if (i == n - 1)
            max[i][1] = p[i][1];
        else if (p[i][1] > max[i + 1][1])
            max[i][1] = p[i][1];
        else
            max[i][1] = max[i + 1][1];
    }
    for (i = 0; i < n - 1; i++) {
        k = p[i][0] - x[i] + max[i + 1][1];
        if (k > ans)
            ans = k;
    }
    for (i = n -1; i > 0; i--) {
        k = p[i][1] - (c-x[i]) + max[i - 1][0];
        if (k > ans)
            ans = k;
    }
  printf("%lld\n", ans);
    return 0;
}


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

int main() {
    string n;
  
   cin >> n;
   string seq = "abcdefghijklmnopqrstuvwxyz";
  
   int min = 26;
  
   for(int i = 0;i < n.size();i++){
     
     
        for(int j = 0;j < 26;j++){
          
            if(n.find(seq[j]) > n.size()){
        
                 if(min > j){
                   
                   min = j;
                    
                 }
                
        
       
             }
        }
     
     
     
     
   }
   
   if(min==26){
     
     cout << "None" << endl;
   }else{
     cout << seq[min] << endl;
   }
     
   
  
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max(a,max3(b,c,d))
using namespace std;
int main()
{
    long long W,H,x,y,flag=0,c=0;
    //scanf("%I64d %I64d %I64d %I64d",&W,&H,&x,&y);
    cin >> W >> H >> x >> y;
    //double a1,a2,a3,a4,a;
    /*a1=W*y;
    a2=W*(H-y);
    a3=H*x;
    a4=H*(W-x);
    a=max4(a1,a2,a3,a4);
    if(a==a4)
    {
        c++;
    }
    if(a==a3)
    {
        c++;
    }
    if(a==a2)
    {
        c++;
    }
    if(a==a1)
    {
        c++;
    }
    if(c>1)
    {
        flag=1;
    }*/
  double s = (double) W * H / 2.0;
  if (W % 2 == 1 || H % 2 == 1)
    {
        flag=0;
    printf("%f %I64d", s, flag);
    return 0;
  }
  if ((H / 2 == x && W / 2 == y) || (H / 2 == y && W / 2 == x))
  {
      flag=1;
    printf("%f %I64d", s, flag);
  }
  else
  {
      flag=0;
     printf("%f %I64d", s, flag);
  }
    //printf("%lf %I64d",a,flag);
    return 0;
}

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

using namespace std;

vector<int> par;

int root(int x) {
  if (par[x] == x) return x;
  else return par[x] = root(par[x]);
}

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  par[x] = y;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> p = vector<int>(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
  }
  par = vector<int>(n + 1);
  for (int i = 1; i <= n; i++) {
    par[i] = i;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    unite(x, y);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (same(i, p[i])) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define num(a) a-'0'
#define charr(a) (a - 'A' + 1)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define all(a) (a).begin(), (a).end()
#define vi vector<long long>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long double ld;
typedef double d;
using namespace std;
int modF=1e9+7;
int INF=1e11;

void solve(){
    int n,m;
    cin>>n>>m;
    v<vi> gr(n);
    int x,y;
    rep(i,0,m){
        cin>>x>>y;
        gr[x-1].pb(y-1);
        gr[y-1].pb(x-1);
    }
    int ans=0;
    vi vis(n,0);
    rep(i,0,n){
        if(vis[i]==0){
            vis[i]=1;
            queue<int> q;
            q.push(i);
            int counter=1;
            while(!q.empty()){
                int x=q.front();
                q.pop();
                for(int e:gr[x]){
                    if(vis[e]==0){
                        vis[e]=1;
                        q.push(e);
                        counter++;
                    }
                }
            }
            maxs(ans,counter);
        }
    }
    cout<<ans<<ln;
}

signed main(){
	boost_io;
	solve();
	return 0;
}


Measured memory_bytes: 18552
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0, i##_len=(n); i<i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

int main(){
          int a,b,c,d;
          cin >> a >> b >> c >> d;
          if((abs(a-b)<=d and abs(c-b)<=d) or abs(a-c)<=d) cout << "Yes" << endl;
          else cout << "No" << endl;
          return 0;
}


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

int main()
{
    string str;
    int sum = 0;

    cin >> str;

    int *N = (int *)calloc(str.length(), sizeof(int));

    for (int i = 0; i < str.length(); ++i)
    {
        N[i] = (int)(str[i] - '0');
    }

    for (int i = 0; i < str.length(); i++)
    {
        sum += N[i];
    }

    if ((sum % 9) == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3908
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<cstdlib>
#include<utility>
#include<bitset>
using namespace std;
const int maxn=(1e5+10);
int n,a[maxn],ans=0;
map<int,int> mp; 
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		mp[a[i]]++;
	}
	map<int,int>::iterator it;
	for(it=mp.begin();it!=mp.end();it++)
	{
		if(it->first>it->second)
		{
			ans+=it->second;
			continue;
		}
		if(it->first==it->second)
		{
			continue;
		}
		ans+=it->second-it->first;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5120
my($n,$k)=split/ /,<STDIN>;
my@p=map{$_-0}split/ /,<STDIN>;
my%s=();
$s{$_}++foreach@p;
my@l=sort{$s{$b}-$s{$a}}keys(%s);
splice @l,0,$k;
$n=0;
$n+=$s{$_}foreach@l;
print $n;

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

int main()
{
    int a;
    string b;
    cin>>a;
    cin>>b;
    int sum=1;
    if(a>1)
    {
        for(int i=1; i<a; i++)
        {
            if(b[i-1]!=b[i])
            {
                sum++;
            }
        }
    }
    else if(a==1)
    {
        sum=1;
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 512
object Main extends App {
  import scala.io.StdIn.{readLine}
  println((0 until readLine().toInt).map{_ ⇒
    val field = FillSpiral(readLine().toInt)
    (0 until field.size).map{y ⇒ (0 until field.size).map{x ⇒ field(x, y)}.mkString}.mkString("","\n", "")
  }.mkString("","\n\n",""))
  case class Coordinate(x:Int, y:Int){
    def +(other:Coordinate):Coordinate = Coordinate(x + other.x, y + other.y)
  }
  class Field(val size:Int){
    private val mArray = Array.tabulate(size){_ ⇒ Array.tabulate(size){_ ⇒ ' '}}
    def apply(x:Int, y:Int):Char = mArray(x)(y)
    def apply(coordinate: Coordinate):Char = mArray(coordinate.x)(coordinate.y)
    def update(x:Int, y:Int, value:Char):Unit = mArray(x)(y) = value
    def update(coordinate: Coordinate, value:Char):Unit = mArray(coordinate.x)(coordinate.y) = value
  }
  object Field{
    def apply(size:Int):Field = new Field(size)
  }
  def FillSpiral(size:Int):Field = {
    val field = Field(size)
    var leftTop = Coordinate(0, 0)
    var rightBottom = Coordinate(size - 1, size - 1)
    while (leftTop.x <= rightBottom.x){
      for (x ← leftTop.x to rightBottom.x){
        field(x, leftTop.y) = '#'
      }
      for (y ← leftTop.y to rightBottom.y){
        field(leftTop.x, y) = '#'
      }
      if (leftTop.y + 1 < rightBottom.y) for (x ← (leftTop.x + 2) to rightBottom.x){
        field(x, rightBottom.y) = '#'
      }
      if (leftTop.x + 1 < rightBottom.x) for (y ← leftTop.y to rightBottom.y){
        field(rightBottom.x, y) = '#'
      }
      if (leftTop.y + 3 <= rightBottom.y && leftTop.x + 4 <= rightBottom.x) field(leftTop.x + 2, rightBottom.y - 1) = '#'
      leftTop = Coordinate(2, 2) + leftTop
      rightBottom = Coordinate(-2, -2) + rightBottom
    }
    field
  }
}



Measured memory_bytes: 48356
def main():
    n = int(input())
    lowest_rank = 0
    lowest_score = 10 ** 9 + 1

    for _ in range(n):
        a, b = map(int, input().split())
        if lowest_rank < a:
            lowest_rank = a
            lowest_score = b

    print(lowest_rank + lowest_score)


if __name__ == "__main__":
    main()


Measured memory_bytes: 74500
#include<algorithm>
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#define INF 10000
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
enum { MaxEdge = 2000 };
int dist[MaxEdge][MaxEdge];
bool used[MaxEdge];

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> edge[MaxEdge];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			dist[i][j] = INF;
		}
	}
	vector<pair<int, int>> E;
	for (int i = 0; i < n-1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		dist[a][b] = 1;
		dist[b][a] = 1;
		E.push_back(P(a, b));
		edge[a].push_back(b); 
		edge[b].push_back(a); 
	}
	for (int i = 0; i < n; i++) {
		dist[i][i] = 0;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)used[j] = false;
		used[i] = true;
		queue<int> que;
		que.push(i);
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (int j = 0; j < edge[v].size(); j++) {
				int nv = edge[v][j];
				if (used[nv])continue;
				dist[i][nv] = dist[i][v] + 1;
				used[nv] = true;
				que.push(nv);
			}
		}
	}
	if (k % 2 == 0) {
		int ans = INF;
		for (int i = 0; i < n; i++) {
			int a = 0;
			for (int j = 0; j < n; j++) {
				if (dist[i][j] > k/2)a++;
			}
			ans = min(ans, a);
		}
		cout << ans << endl;
	}
	else {
		int ans = INF;
		for (int i = 0; i < E.size(); i++) {
			int a = 0;
			for (int j = 0; j < n; j++) {
				if (dist[E[i].first][j] > k/2&&dist[E[i].second][j]>k/2) {
					a++;
				}
			}
			ans = min(ans, a);
		}
		cout << ans << endl;
	}

}

Measured memory_bytes: 16000
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader vd = new BufferedReader(new InputStreamReader(System.in));
		String[] cd = vd.readLine().split("");
		int n=0;
		for(int i=0;i<cd.length;++i) {
			if(Integer.parseInt(cd[i])==1) n++;
		}
		System.out.println(n);
	}

}


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


using namespace std;
using ll = long long;

const int sz = 2e5 + 10;
int a[sz];
int n, k, tmp;

bool work(int p) {
    int cuts = 0;
    for(int i = 0; i < n; i++) {
        int c = a[i] / p;
        if((c * p) == a[i]) {
            cuts += c - 1;
        } else {
            cuts += c;
        }
    }
    return cuts <= k;
}


int main() {
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int l = 1, r = 1e9;
    while(l < r) {
        int mid = (l + r) / 2;
        if(work(mid)) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    cout << r << "\n";




    return 0;
}



Measured memory_bytes: 4364
#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)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b,x,sum=0;
  cin>>a>>b>>x;
  if(a>b*2){
    sum=(x/500)*b;
    x%=500;
  }
  else{
    sum=(x/1000)*a;
    x%=1000;
  }

  if(x>500){
    b*=2;
  }
  if(x==0){
    cout<<sum<<'\n';
    return(0);
  }
  if(a>b){
    sum+=b;
  }
  else{
    sum+=a;
  }
  cout<<sum<<'\n';
  return(0);
}



Measured memory_bytes: 3228
def resolve():
    N, X, Y = map(int, input().split())
    X -= 1
    Y -= 1
    from collections import defaultdict, deque
    ans = [0] * N
    for i in range(N):
        queue = deque([(i, 0)])
        d = [float('inf')] * N
        while queue:
            node, dist = queue.popleft()
            if d[node] != float('inf'):
                continue
            d[node] = dist
            if node == X:
                queue.append([Y, dist+1])
            if node == Y:
                queue.append([X, dist+1])
            if node + 1 < N:
                queue.append([node+1, dist+1])
            if node - 1 >= 0:
                queue.append([node-1, dist+1])
        for j in range(N):
            ans[d[j]] += 1
    for i in range(1, N):
        print(ans[i]//2)
resolve()


Measured memory_bytes: 73180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
#define sort(a) sort(a.begin(),a.end());
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define F first
#define S second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
#define TC cin>>t;while(t--)
const ll MOD = 1e9+7;
const ld PI = 3.1415926535898;
const ll LLMAX = LLONG_MAX;

int main()
{
    int n,k;
    cin>>n>>k;
    ll sum=0;
    for(ll i=k;i<=n+1;i++)
    {
        ll mx=i*(2*n-i+1)/2;
        ll mn=i*(i-1)/2;
        sum+=(mx-mn+1)%MOD;
        sum%=MOD;
    }
    cout<<sum<<nl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
ll a[N], n;

ll f(ll x)
{
	ll s = 0;
	for(int i = 1; i <= n; i ++)
		s += abs(a[i] - (x + i));
	return s;
}
int main()
{
	cin >> n;
	for(int i= 1; i <= n; i ++)
		cin >> a[i];
	ll l = -1e9-1, r = 1e9+2;
	ll ans = 1e14, cnt = 200;
	for(;cnt;cnt--)
	{
		ll mid1 = (l + l + r) / 3;
		ll mid2 = (l + r + r) / 3;
		ll f1 = f(mid1), f2 = f(mid2);
		if(f1 < f2)
		{
			r = mid2;
		}
		else
			l =  mid1;
//		cerr << l << ' ' << r << '\n';
		umin(ans, (ll)(min(f1, f2)));
	}



	cout << ans;
	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 1792
#include <vector> // vectorを使うためにインクルードする
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
	int N;
	cin >> N;
	vector<int> vec;
	string s;
	cin >> s;
	for(int i=0;i<N;i++){
		if(i==0){
			if(s[i]=='(')vec.push_back(1);
			else{vec.push_back(-1);}
		}
		else if(s[i]=='('){vec.push_back(vec[i-1]+1);}
		else{vec.push_back(vec[i-1]-1);}
	}

		int mini = -1*(*min_element(vec.begin(),vec.end()));
		if(mini<0)mini=0;
		int last = mini + vec[N-1];

    for(int i=0;i<mini;i++){
			cout << "(";
		}
		for(int i=0;i<N;i++){
			cout << s[i];
		}
		for(int i=0;i<last;i++){
			cout << ")";
		}
		cout << endl;

	}


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

struct Event {
    int when, value, type;
    Event() {}
    Event(int _when, int _value, int _type): when(_when), value(_value), type(_type) {}
};

bool compareEvent(Event a, Event b) {
    return a.when < b.when;
}

int N, Q;
vector<Event> events;

int main() {
    scanf("%d%d", &N, &Q);
    for (int i = 0; i < N; i++) {
        int S, T, X;
        scanf("%d%d%d", &S, &T, &X);

        events.push_back({S - X, X, +1});
        events.push_back({T - X, X, -1});
    }

    sort(events.begin(), events.end(), compareEvent);

    int ptrEvent = 0;
    multiset<int> Xs;
    for (int i = 0; i < Q; i++) {
        int D;
        scanf("%d", &D);

        while (ptrEvent < events.size() && D >= events[ptrEvent].when) {
            auto event = events[ptrEvent];
            if (event.type == 1)
                Xs.insert(event.value);
            else
                Xs.erase(Xs.find(event.value));

            ptrEvent += 1;
        }

        if (Xs.size() == 0)
            printf("-1\n");
        else
            printf("%d\n", *(Xs.begin()));
    }
}


Measured memory_bytes: 16236
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long n;
	cin >> n;
	int i;
	for(i=sqrt(n);i>1&&n%i!=0;i--);
	cout << (int)max(log10(i)+1,log10(n/i)+1) << "\n";
	return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    static int[] P, Q;
    static int p, q, c;

    public static void main(String[] args) {
        int N = in.i();
        P = in.ii(N);
        Q = in.ii(N);
        p = q = c = 1;
        permutation(0, N, new boolean[N], new int[N]);
        out.println(Math.abs(p - q));
    }

    static void permutation (int i, int n, boolean[] used, int[] arr) {
        if (i == n) {
            if (Arrays.equals(P, arr)) {
                p = c;
            }
            if (Arrays.equals(Q, arr)) {
                q = c;
            }
            c++;
        } else {
            for (int j = 0; j < n; j++) {
                if (!used[j]) {
                    used[j] = true;
                    arr[i] = j + 1;
                    permutation(i + 1, n, used, arr);
                    used[j] = false;
                }
            }
        }
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 33932
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	d := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&d[i])
	}

	m := make(map[int]bool)
	for _, v := range d {
		if !m[v] {
			m[v] = true
		}
	}
	fmt.Println(len(m))
}


Measured memory_bytes: 640
import java.util.*; 
class Main 
{
public static void main(String args[]) 
{
Scanner sc = new Scanner(System.in); 
int n = sc.nextInt(); 
int value = 1000;


while(value<n)
{
value=value+1000;
}  

System.out.print(value-n);
} 
}

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

int main(int argc, char const *argv[]) {
  string s;
  int ans = 0;
  cin >> s;
  for (size_t i = 0; i < 3; i++)
    if (s[i] == '1') ans++;
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    ll s = 0;
    rep(i, n) cin >> a[i];

    ll minv = 1e15;
    ll front_sum = 0, back_sum = accumulate(ALL(a), (ll)0);
    ll sum = 0;

    rep(i, n - 1)
    {
        front_sum += a[i];
        back_sum -= a[i];
        minv = min(minv, abs(front_sum - back_sum));
    }

    OP(minv);

    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
int max(int a, int b) {return (a > b) ? a : b;}
int main()
{
	int n, maxn = 0, hb = 0;
	char c[101];
	scanf("%d",&n);
	scanf("%s",&c);
	for(int i = 0;i < n;i++)
	{
		if(c[i] == 'I') hb++;
		else if(c[i] == 'D') hb--;
		maxn = max(maxn, hb);
	}
	printf("%d\n",maxn);
	return 0;
}

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

using namespace std;

int main(void) {
    int N, Z, W;
    cin >> N >> Z >> W;
    vector<int> a(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }
    int X, Y;
    if(N == 1) {
        cout << abs(a[0] - W) << endl;
    } else {
        if(abs(a[N-1]-W) >= abs(a[N-2]-a[N-1])) {
            cout << abs(a[N-1]-W) << endl;
        } else {
            cout << abs(a[N-2]-a[N-1]) << endl;
        }
    }
    return 0;
}


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

int main() {
  int a;
  cin>>a;
  int b=a;
  int n=1;
  while(a/10>=1) {
    a/=10;
    n+=1;
  }
  int ans=0;
  if (n==1) {
    ans=b;
  } else if (n%2==0) {
    for (int i=0;i<n/2;++i) {
      ans+=9*(pow(10,(i*2)));
    }
  } else {
    for (int i=0;i<n/2;++i) {
      ans+=9*(pow(10,(i*2)));
    }
    int l=pow(10,(n-1));
    ans+=(b-l);
    ans+=1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder_172A
{
    class Program
    {
        static void Main(string[] args)
        {
            double a = double.Parse(Console.ReadLine());
            double calc = a + Math.Pow(a,2) + Math.Pow(a,3);
            Console.WriteLine(calc);
            //Console.ReadKey();
        }
    }
}

Measured memory_bytes: 27684
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if((a+b==c)||(a+c==b)||(b+c==a)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long LL;

const int N=310,Mod=1e9+7;

struct Edge{ int to,next,cost; }way[N<<1];

int n,m,R[N][N],B[N][N],G[N][N],tot,num[N];

void Build(int a,int b,int c){ way[++tot]=(Edge){b,num[a],c}; num[a]=tot; }

void Init()
{
	scanf("%d%d",&n,&m);
	int l,r,x;
	for (int i=1;i<=m;++i)
	{
		scanf("%d%d%d",&l,&r,&x);
		if (l>r) swap(l,r);
		Build(r,l,x);
	}
}

void Solve()
{
	R[0][0]=1; B[0][0]=1; G[0][0]=1;
	for (int i=1;i<=n;++i)
	{
		for (int j=num[i];j;j=way[j].next)
		{
			int to=way[j].to,v=way[j].cost;
			switch (v)
			{
				case 1:
					for (int a=0;a<i;++a)
						for (int b=0;b<i;++b)
							if (a>=to || b>=to) R[a][b]=B[a][b]=G[a][b]=0;
					break;
				case 2:
					for (int a=0;a<i;++a)
						for (int b=0;b<i;++b)
							if (a<to && b<to) R[a][b]=B[a][b]=G[a][b]=0;
							else if (a>=to && b>=to) R[a][b]=B[a][b]=G[a][b]=0;
					break;
				case 3:
					for (int a=0;a<i;++a)
						for (int b=0;b<i;++b)
							if (a<to || b<to) R[a][b]=B[a][b]=G[a][b]=0;
					break;
			}
		}
		if (i==n) break;
		for (int a=0;a<i;++a)
			for (int b=0;b<i;++b)
			{
				B[i][b]=(B[i][b]+R[a][b])%Mod; G[i][a]=(G[i][a]+R[a][b])%Mod;
				R[i][b]=(R[i][b]+B[a][b])%Mod; G[a][i]=(G[a][i]+B[a][b])%Mod;
				R[b][i]=(R[b][i]+G[a][b])%Mod; B[a][i]=(B[a][i]+G[a][b])%Mod;
			}
	}
	LL sum=0;
	for (int a=0;a<n;++a)
		for (int b=0;b<n;++b)
			sum=(sum+R[a][b]+B[a][b]+G[a][b])%Mod;
	printf("%lld\n",sum);
}

int main()
{
	Init();
	Solve();
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = 0;
    if (2 * c < a + b)
    {
        while (x > 0 && y > 0)
        {
            ans += 2 * c;
            x--;
            y--;
        }
    }
    while (x > 0)
    {
        ans += min(2 * c, a);
        x--;
    }
    while (y > 0)
    {
        ans += min(2 * c, b);
        y--;
    }

    cout << ans << endl;

    return 0;
}

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

int gcdLeft[100100];
int gcdRight[100100];
int a[100100];

int gcd(int x, int y){
    return y == 0 ? x : gcd(y, x % y);
}

int main(){
    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        gcdLeft[i] = gcd(a[i], gcdLeft[i-1]);
    }
    for(int i=n; i>0; i--){
        gcdRight[i] = gcd(a[i], gcdRight[i+1]);
    }

    int ma = 0;
    for(int i=1; i<=n; i++){
        ma = max(ma, gcd(gcdLeft[i-1], gcdRight[i+1]));
    }
    cout << ma << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    multiset<long long> v;
    for (int i = 0; i < n; i++) {
        long long d; cin >> d; v.insert(d);
    }
    vector<pair<long long, int>> d;
    for (int i = 0; i < m; i++) {
        int b, c; cin >> b >> c;
        d.emplace_back(c, b);
    }
    sort(d.rbegin(), d.rend());
    long long ans = 0; int l = 0;
    for (int in = 0; in < m; in++) {
        auto it = d[in];
        while (!v.empty() && *v.begin() < it.first && it.second) {
            v.erase(v.begin());
            ans += it.first; it.second--;
        }
    }
    for (auto x: v) {
        ans += x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7156
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define reps(i,s,n) for (int i = s; i < n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
#define all(c) begin(c),end(c)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const long double pi = acos(-1.0);
typedef complex<ld> cd;

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

    int k;
    cin >> k;
    vector<ll> a(k);
    rep(i,k) cin >> a[i];

    ll min_n = 2, max_n = 2;
    per(i, k) {
        ll min_num = ((min_n + a[i] - 1) / a[i]) * a[i];
        ll max_num = (max_n / a[i]) * a[i] + a[i] - 1;
        if(min_num > max_n || max_num < min_n){
            cout << -1 << endl;
            return 0;
        }
        min_n = min_num;
        max_n = max_num;
    }
    cout << min_n << " " << max_n << endl;
}


Measured memory_bytes: 1024
n,m = map(int,input().split())
tmp = input()
a = tmp.split()
a = list(map(int,a))

limit = sum(a) / (4 * m)
count = 0
for i in a:
    if i >= limit:
        count += 1

if count >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
def main():
    N = input()
    A = [v for v in map(int, input().split()) if v % 2 == 0]
    for a in A:
        if a % 3 != 0 and a % 5 != 0:
            print("DENIED")
            exit()
    print("APPROVED")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61908
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
using ll =long long;

int main (void) {
  string A,B;
  cin >> A >> B;
  if(A.size()==B.size()){
    for (int i=0; i<A.size(); i++) {
      if(A[i]>B[i]){
        cout<< "GREATER";
        return 0;
      }
      else if(A[i]<B[i]){
        cout<< "LESS";
        return 0;
      }
      else{
        if(A[A.size()-1]==B[A.size()-1]){
          cout << "EQUAL";
          return 0;
        }
        continue;
      }
    }
  }
  else if(A.size()>B.size()){
    cout<< "GREATER";
    return 0;
  }
  else {
    cout<< "LESS";
    return 0;
  }
}

Measured memory_bytes: 256
program answer
  implicit none
  integer(8) :: H, W, i, j
  character(len=100), allocatable :: C(:)
  read(*,*) H, W
  allocate(C(H))
  do i = 1, H
     read(*,*) C(i)
  end do


  do i = 1, 2*H
        if(mod(i,2)==0) then
           write(*,*) C(i/2)
        else
           write(*,*) C((i+1)/2)
        end if
  end do

  deallocate(C)
  stop
 end program answer

Measured memory_bytes: 2856
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <deque>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <complex>
#include <cstring>
#include <iomanip>
#include <bitset>

using namespace std;
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, a, b) for(int i = (a); i > (b); i--)
#define forIt(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define ft(a) __typeof((a).begin())
#define ll long long
#define ld long double
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define bitcount(n) __builtin_popcountll(n)


typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef pair<ll, ll> pll;

const int N = 1000 + 7;
const int M = 30;
const int inf = 1e9 + 7;
const long long linf = (ll) inf * inf + 7;
const double pi = acos(-1);
const double eps = 1e-20;
const bool multipleTest = false;

set<ii> st[26];
string s;

int sum[26];


void solve() {
    cin >> s;
    
    
    int n = sz(s);
    
    for(int i = 1; i <= n; ++i) {
        int u = s[i - 1] - 'a';
        sum[u] ++;
        if (i > 1) {
            int cur = i - 2 * sum[u];
            typeof(st[u].begin()) it = st[u].upper_bound(mk(cur, n + 1));
            if (it != st[u].end() && i - it->second > 1) {
                cout << it->second + 1 << " " << i;
                return;
            }
        }
        for(int j = 0; j < 26; ++j) {
            if (j != u) st[j].insert(mk(i - 1 - 2 * sum[j], i - 1));
            else st[j].insert(mk(i - 1 - 2 * (sum[j] - 1), i - 1));
        }
    }
    
    cout << "-1 -1";
    
}

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    auto t1 = clock();
//#endif
//
    
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    
    for(int i = 0; i < Test; ++i) {
        solve();
    }
    
//#ifndef ONLINE_JUDGE
//    printf("\n%.9lf\n", (0.0 + clock() - t1) / CLOCKS_PER_SEC);
//#endif
}

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

const int M = 1000005;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> cnt(M);
  for(int x: a) {
    if (cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for(int i=x; i<M; i+=x) cnt[i]++;
  }
  int ans=0;
  for(int x: a) {
    if(cnt[x]==1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7952
#include<stdio.h>
#define MAX 100

int number[MAX][MAX];

int main(void){

 int a,b,c,i,j,l;

 scanf("%d",&l);

 for(i=0; i<l; i++){
 scanf("%d",&a);
 scanf("%d",&b);

  for(j=0; j < b; j++){
  scanf("%d",&c);
  number[a-1][c-1] =1;
  }
 }
 for(i =0; i<l; i++){
  for(j=0; j<l-1; j++){
   printf("%d ",number[i][j]);
  }
 printf("%d\n",number[i][j]);
 }
 return 0;
}

Measured memory_bytes: 628
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;

ll n, k, q;
ll a[114514];
ll cnt[114514];

int main(){
  cin >> n >> k >> q;
  for(int i=0;i<q;i++){
    cin >> a[i]; a[i]--;
    cnt[a[i]]++;     
  }
  for(int i=0;i<n;i++){
    if (k > q - cnt[i]){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}
  

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0; i<N; i++)
#define lint long long
#define square_vector(name,N,M) vector<vector<lint>>name(N,vector<lint>(M,0))
#define sort(V) sort(V.begin(),V.end())

int main() {
  int N;
  string S,T;
  cin >> N >> S >> T;
  for (int i=0; i<N; i++) {
    cout << S[i] << T[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long int
#define pii pair<int,int>
#define mii map<int,int>
#define f first
#define s second
#define mp make_pair
using namespace std;

int main() 
{
	int n;
    cin>>n;
     vector<int>arr(n,0);
     map<int,int>mp;
    for(int i=0;i<(n-1);i++)
    {
      cin>>arr[i];
      mp[arr[i]]++;
    } 
    for(int i=1;i<=n;i++)
      cout<<mp[i]<<"\n";
	return 0;
}

Measured memory_bytes: 13556
#include<stdio.h>

	int main(){
	
		int x[101]={},y[101]={},z,i,max=0;
		
		while( scanf("%d",&z) != EOF){
			x[z]=x[z]+1;
			if(max<=x[z]){
				max=x[z];
				y[z]=max;
			}
		}
		
		for(i=1;i<101;i++){
			if(max==y[i]){
				printf("%d\n",i);
			}
		}
	
	return 0;
}

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

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

    vector<long> A(N);
    long sum = 0, A_n;
    long sum_even = 0, sum_odd = 0;
    for (int n = 0; n < N; n++) {
        cin >> A_n;
        A[n] = A_n;
        sum += A_n;
        if (n % 2 == 0) {
            sum_even += A_n;
        } else {
            sum_odd += A_n;
        }
    }
    sum /= 2;

    vector<long> Ans(N);
    for (int n = 0; n < N; n++) {
        if (n % 2 == 1) {
            Ans[n] = A[n - 1] - Ans[n - 1];
        } else {
            Ans[n] = sum - sum_odd;
            sum_odd = sum_odd - A[n + 1] + A[n];
        }
    }

    for (int n = 0; n < N; n++) {
        if (n == N - 1) {
            cout << Ans[n] * 2 << "\n";
        } else {
            cout << Ans[n] * 2 << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 2944
#include<stdio.h>
int main()
{
	long long a,b,c=0,d=0,e;
	scanf("%lld %lld",&a,&b);
	c=a*b;
	if(a<b){
		e=a;
		a=b;
		b=e;
	}
	d=a%b;
	while(d!=0){
		a=b;
		b=d;
		d=a%b;
	}
	printf("%lld\n",c/b);
	return 0;
}

Measured memory_bytes: 1720
#include <iostream>
#include<cmath>

using namespace std;

int main(){
  int X; cin>>X;
  int num=sqrt(X);
  int ans=1;
  for(int i=2;i<=num;i++){
    int a=0;
    while(pow(i,a+1)<=X){
      a++;
    }
    if(ans<=pow(i,a)) ans=pow(i,a);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
let calc = function
  | 25 -> "Christmas"
  | 24 -> "Christmas Eve"
  | 23 -> "Christmas Eve Eve"
  | 22 -> "Christmas Eve Eve Eve"
  | n  -> string_of_int n

let () =
  let n = Scanf.scanf "%d" (fun n -> n) in
  calc n |> print_endline



Measured memory_bytes: 384
n, m = map(int, input().split())
a = list(map(int, input().split()))

from math import floor
import heapq

for i in range(n):
	a[i] = -a[i]

h = []
for ele in a:
	heapq.heappush(h, ele)

for _ in range(m):
	mx = heapq.heappop(h)
	mx /= 2
	heapq.heappush(h, mx)

ans = 0
for ele in h:
	ans += floor(-ele)

print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <cstdlib>

using namespace std;

int n = 0;
int even[10] = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9};
int edigit = 0;
int odigit = 0;
int sum = 0;
char ID[100001];
int m = 0;
int a[10];
int answer = 0;

int dfs(int depth, int _sum) {
    int count = 0;
    if (depth < edigit) {
        for (int i = 0; i < m; i++) count += dfs(depth+1, _sum+even[a[i]]);
    } else if (depth < edigit + odigit) {
        for (int i = 0; i < m; i++) count += dfs(depth+1, _sum+a[i]);
    } else if ((sum+_sum) % 10 == 0) count = 1;

    return count;
}

int main() {
    cin>>n;
    cin>>ID;
    for (int i = 0; i < n; i++) {
        char str[2] = {ID[i], '\0'};
        if (ID[i] == '*') (n-i) % 2 == 0 ? edigit++: odigit++;
        else (n-i) % 2 == 0 ? sum += even[atoi(str)] : sum += atoi(str);
    }
    sum %= 10;
    cin>>m;
    for (int i = 0; i < m; i++) cin>>a[i];
    cout<<dfs(0, 0)<<endl;
}

Measured memory_bytes: 3180
#include <iostream>

using namespace std;

int main() {
	int a,b,c;
    cin >> a >> b >> c;
    if(a==b && c!=a){
     cout << "Yes" << endl;
     }
    else if(a==c and b!=a){
     cout << "Yes" << endl;
     }
    else if(b==c and a!=b){
     cout << "Yes" << endl;
     }
    else{
     cout << "No" << endl;
    }
	return 0;
}

Measured memory_bytes: 256