akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
//#include <cmath>
#include <climits>


using namespace std;






int main() {






//    freopen("/Users/balazskemenes/Documents/temp/practise/src/problems/input.txt","r",stdin);






    int studentCount;
    cin >> studentCount;

    int checkpointCount;
    cin >> checkpointCount;




    vector<int> studentsX;
    vector<int> studentsY;

    vector<int> checkpointsX;
    vector<int> checkpointsY;


    for(int i = 0; i < studentCount; ++i) {


        int sX;
        int sY;

        cin >> sX;
        cin >> sY;


        studentsX.emplace_back(sX);
        studentsY.emplace_back(sY);

    }





    for(int i = 0; i < checkpointCount; ++i) {


        int cX;
        int cY;

        cin >> cX;
        cin >> cY;


        checkpointsX.emplace_back(cX);
        checkpointsY.emplace_back(cY);

    }


    for(int i = 0; i < studentCount; ++i) {


        int sX = studentsX[i];
        int sY = studentsY[i];


        double minDistance = INT_MAX;

        int checkpointId = 0;

        for(int j = 0; j < checkpointCount; ++j) {


            int cX = checkpointsX[j];
            int cY = checkpointsY[j];


            double currentDistance = abs(sX - cX) + abs(sY - cY);


            if(currentDistance < minDistance) {


                minDistance = currentDistance;


                checkpointId = j + 1;

            }




        }



        cout << checkpointId << endl;


    }


// ------------------------------------------------------------------------------------------








//    freopen("/Users/balazskemenes/Documents/temp/practise/src/problems/input.txt","r",stdin);


//
//    unsigned long long N;
//    cin >> N;
//
//
//
//    unsigned long long startValue = sqrt(N);
//
//
//    unsigned long long startValueCopy = N;
//
//
//    int minLength=0;
//    for(;startValueCopy;startValueCopy/=10) minLength++;
//    minLength = minLength==0 ? 1 : minLength;
//
//
//
//
//    for(int i = startValue; i <= N; ++ i) {
//
//
//        if(N % i == 0) {
//
//            unsigned long long rightSide = N / i;
//
//
//            unsigned long long leftSide = i;
//            unsigned long long originalRightSide = rightSide;
//
//            int leftSideLength=0;
//            for(;leftSide;leftSide/=10) leftSideLength++;
//            leftSideLength = leftSideLength==0 ? 1 : leftSideLength;
//
//
//
//
//
//
//            int rightSideLength=0;
//            for(;rightSide;rightSide/=10) rightSideLength++;
//            rightSideLength = rightSideLength==0 ? 1 : rightSideLength;
//
//
//
//
//
//
//
//            minLength = max(leftSideLength, rightSideLength);
//
//
//
//
//
//            break;
//
//
//
//        }
//
//
//
//
//    }
//
//
//
//
//    cout << minLength;
//

















    return 0;
}















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

int main() {
  std::map<std::string, int> d;
  int n; std::cin >> n;
  while (n--) {
    std::string s; std::cin >> s;
    ++d[s];
  }
  std::cout << "AC" << " x " << d["AC"] << std::endl;
  std::cout << "WA" << " x " << d["WA"] << std::endl;
  std::cout << "TLE" << " x " << d["TLE"] << std::endl;
  std::cout << "RE" << " x " << d["RE"] << std::endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include "stdio.h"
int main(void)
{
	/* code */
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a>b)
		printf("a > b\n");
	else if(a<b)
		printf("a < b\n");
	else
		printf("a == b\n");
	return 0;
}


Measured memory_bytes: 580
#include "bits/stdc++.h"
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmax(x, y) (x > (y) ? x : x = (y))
#define chmin(x, y) (x < (y) ? x : x = (y))
#define write(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = INT32_MAX / 2;
const int MAX = 1e5 + 10;

int N;
string A, B, C;

int main()
{
    cin >> N >> A >> B >> C;
    int cnt = 0;
    rep(i, N) {
        int n = 0;
        if (A[i] != B[i]) n++;
        if (C[i] != A[i] && C[i] != B[i]) n++;
        cnt += n;
    }
    write(cnt);
}

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

int main() {
    string s;
    cin >> s;
    int l = s.size();
    for (int i = 0; i <= 7; i++) {
        if (s.substr(0, i) + s.substr(l - 7 + i, 7 - i) == "keyence") {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<limits>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>


using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)


double c(double x)
{
  double X = x;
  X = int(X) % 10;
  return X;
}

int main()
{
  int a,b;
  cin >> a >> b;
  for(int i = 1;i < 1010;i++)
  {
    if(int(i*0.08) == a && int(i*0.1) == b)
    {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#define SIZE 33554432
char Key[128];
int Hash(const char* c)
{
    int Hash = 1;
    while(*c){
        Hash  <<= 2;
        Hash += Key[*c];
        ++c;
    }
    return Hash;
}
int main()
{
    Key['A'] = 0;
    Key['C'] = 1;
    Key['G'] = 2;
    Key['T'] = 3;
    bool* dic = new bool[SIZE];
    int n;
    std::scanf("%d\n", &n);
    char str[21];
    for(int i = 0; i < n; ++i){
        std::gets(str);
        if(str[0] == 'i'){
            dic[Hash(str+7)] = true;
        }else{
            std::puts((dic[Hash(str+5)] ? "yes" : "no"));
        }
    }
    return 0;
}

Measured memory_bytes: 4132
h,w=map(int,input().split())
s=[input().split() for _ in range(h)]
x,y=0,0
for i in range(h):
    for j in range(w):
        if s[i][j]=="snuke":
            x,y=i,j
print(chr(y+ord('A'))+str(x+1))

Measured memory_bytes: 38512
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
using namespace std;

int main(){
  int n; cin >> n;
  int a = 0, b = 0;
  for(int i = 0; i < n; i++){
    string sa,sb; cin >> sa >> sb;
    if(sa == sb){
      a++;
      b++;
    }else if(sa < sb) b += 3;
    else a += 3;
  }
  cout << a << " " << b << endl;
  return 0;
}



Measured memory_bytes: 3152
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
typedef long long LL;
const int N=2e5+10;
struct node{
	int cnt0,cnt1,id;
	inline bool operator <(node x)const{
		return 1ll*cnt0*x.cnt1<1ll*cnt1*x.cnt0;
	}
};
__gnu_pbds::priority_queue <node> q;
__gnu_pbds::priority_queue <node>::point_iterator it[N];
int n,p[N],v[N],fa[N],a[N],b[N];
inline int getf(int u){return fa[u]==u?u:fa[u]=getf(fa[u]);}
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; ++i)fa[i]=i;
	for(int i=2; i<=n; ++i)scanf("%d",&p[i]);
	for(int i=1; i<=n; ++i)scanf("%d",&v[i]),a[i]=!v[i],b[i]=v[i],it[i]=q.push(node{!v[i],v[i],i});
	LL ans=0;
	while(!q.empty()){
		node x=q.top(); q.pop();
		int u=x.id; fa[u]=getf(p[u]);
		ans+=1ll*b[fa[u]]*a[u]; a[fa[u]]+=a[u]; b[fa[u]]+=b[u];
		if(fa[u])q.modify(it[fa[u]],{a[fa[u]],b[fa[u]],fa[u]});
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 15232
def solve():
    N = int(input())
    l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    return l[N-1]

print(solve())

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ro(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
typedef vector<ll> vi;
ll n,k,sm = 0;
int main()
{
	cin>>n>>k;
	vi vo(n);
	for(ll &i:vo){
		cin>>i;
	}
	sort(ro(vo));
	for(ll i = 0;i<k;i++){
		sm+=vo[i];
	}
	cout<<sm<<"\n";
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long ll;

const int maxn = 2e5 + 7;

int n, x;

struct node {
  int b, l, u;
  ll sorce;
  friend bool operator < (const node& x, const node& y) {
    return x.sorce > y.sorce;
  }
} a[maxn];

ll check(ll t) {
  ll tim = t / x;
  ll res = t - tim * x;
  ll sum = 0;
  for (int i = 1; i <= tim; i++) {
    sum += a[i].sorce;
  }
  ll ans = 0;
  //ans = sum;
  for (int i = 1; i <= n; i++) {
    ll now = 0;
    if (res <= a[i].b) 
      now = res * a[i].l;
    else 
      now = (long long)a[i].b * a[i].l + (long long)(res - a[i].b) * a[i].u;
    if (i <= tim) ans = max(ans, sum - a[i].sorce + now + a[tim + 1].sorce);
    else ans = max(ans, sum + now);
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  //cin.tie(0);
  //cout.tie(0);
  cin >> n >> x;
  ll goal = 0, maxx = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].b >> a[i].l >> a[i].u;
    goal += (long long)a[i].b * a[i].l;
    a[i].sorce =(long long )a[i].b * a[i].l + (long long) a[i].u * (x - a[i].b);
  }
  sort(a + 1, a + n + 1);
  ll l = 0, r = (long long)n * x;
  while (l < r) {
    ll mid = (l + r) / 2;
    if (check(mid) >= goal) r = mid;
    else l = mid + 1;
  }
  cout << r << endl;
}

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

int main() {
  int n;
  cin>>n;
  vector<char> stone(n);
  for(int i=0;i<n;i++){
    cin>>stone.at(i);
  }
  
  int white=0;
  int red=0;
  for(int i=0;i<n;i++){
    if(stone.at(i)=='W')
      white++;
    if(stone.at(i)=='R')
      red++;
  }
    int clear=0;
    for(int i=0;i<red;i++){
      if(stone.at(i)=='W')
        clear++;
    }
  cout<<clear<<endl;
}


Measured memory_bytes: 3564
import java.io.*;

public class Main {
  
  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] in = br.readLine().split(" ");

    br.close();

    System.out.println(in[2] + " " + in[0] + " " + in[1]);
  }
}

Measured memory_bytes: 21076
import java.io.*;
import java.util.*;
class Main{
    public static void main(String args[]) throws IOException{

	int a=0;
	int b=0;
	int c=0;
	int i=0;
	int k=0;

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String str = br.readLine();
	String delimiter = " ";
        StringTokenizer stringTokenizer = new StringTokenizer( str, delimiter );
	while(stringTokenizer.hasMoreTokens())
	{
            String current = stringTokenizer.nextToken();
	    if(i==0)a=Integer.parseInt(current);
	    if(i==1)b=Integer.parseInt(current);
	    if(i==2)c=Integer.parseInt(current);
	    i++;
	}
	for(int j=a;j<=b;j++){
	    if(c%j==0){
		k++;
	    }
	}
	System.out.println(k);
    }
}

Measured memory_bytes: 16880
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;

//a^n modをO(logN)で計算
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//a/bをmodで割った余り、フェルマーの小定理
int64_t div(int64_t a,int64_t b,int64_t mod){
    return (a%mod)*(modpow(b,mod-2,mod)%mod)%mod;
}
// a-bをMODで割ったあまり、負にならない工夫
long long sub(long long a,long long b){
    long long ans = ((a%MOD)-(b%MOD))%MOD;
    if(ans>=0){
        return ans;
    }
    else{
        return ans+MOD;
    }
}
int main(){
    int n;
    cin>>n;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    int64_t ans=0;
    ans = sub(sub(modpow(10,n,MOD),modpow(9,n,MOD)),modpow(9,n,MOD))+modpow(8,n,MOD);
    cout<<ans%MOD<<endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#define    ROW 100
#define COLUMN 100

int main()
{
  int matA[ROW][COLUMN]={},matB[COLUMN]={},n,m,i,j,c=0;

  scanf("%d %d", &n,&m);

  for(i = 0 ; i < n ; i++)
    {
      for(j = 0 ; j < m ; j++) scanf("%d",&matA[i][j]);     
    }

  for(i = 0 ; i < m ; i++)
    {
      scanf("%d",&matB[i]);
      
    }
  
  for(i = 0 ; i < n ; i++)
    {
      for(j = 0 ; j < m ;j++ )
	{
	  c += matA[i][j]*matB[j];
	}

      printf("%d\n",c);
      c = 0;
    }
  
  return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S = to_string(N);
  while (N % 10 == 0) N/=10;
  if (N == 1){
    cout << 10;
  } else {
    int ans = 0;
    for (int i = 0; i < S.size(); i++){
      ans += S[i] - '0';
    }
    cout << ans;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
using namespace std;

int main(){
    string s;
    cin >> s;
    long ans = 0;
    for(int i = 0; i < (1 << (s.length() - 1)); i++){
        long sum = 0;
        long tmp = 0;
        for(int j = 0; j < s.length(); j++){
            tmp = tmp * 10 + stol(s.substr(j, 1));
            if(((i >> j) & 1) == 1){
                sum += tmp;
                tmp = 0;
            }
        }
        sum += tmp;
        ans += sum;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//    ____       ____                 _           
//   |  _ \ _ __|  _ \  ___ _ __   __| |_ __ ___  
//   | | | | '__| | | |/ _ \ '_ \ / _` | '__/ _ \ 
//   | |_| | |_ | |_| |  __/ | | | (_| | | | (_) |
//   |____/|_(_)|____/ \___|_| |_|\__,_|_|  \___/ 
//                                                

 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define f first
#define s second
#define pb push_back
#define ll long long

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll LLOO = 1e18+7;
const ll OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 2e3+7;

int n;
int a[N];
ll mem[N][N];
vector<pair<ll,ll> > vec;

ll dp(int l,int r)
{
	ll &ret = mem[l][r];
	if (ret != -1) return ret;
	if (l > r) return 0;
	ll ch1 = dp(l+1,r)+vec[l+n-1-r].f*abs(vec[l+n-1-r].s-l);
	ll ch2 = dp(l,r-1)+vec[l+n-1-r].f*abs(vec[l+n-1-r].s-r);
	return ret = max(ch1,ch2);
}

int main()
{
	memset(mem,-1,sizeof mem);
	scanf("%d",&n);
	rep(i,n) scanf("%d",a+i);
	rep(i,n) vec.pb({a[i],i});
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());
	printf("%lld\n",dp(0,n-1));
    return 0;
}



Measured memory_bytes: 35460
using System;
class main{
	public static void Main(){
		string[] str = Console.ReadLine().Split();
		int a = int.Parse(str[0]), b = int.Parse(str[1]);
		if ((a < b))
		{
			Console.WriteLine("a < b");
		}
		else if (a > b)
		{
			Console.WriteLine("a > b");
		}
		else Console.WriteLine("a == b");
	}
}

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

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

LL kaijo(LL n){
    LL ans=1;
    for(LL i=1;i<=n;++i){
        (ans*=i)%=MOD;
    }
    return ans;
}


int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a+b+c-max(a,max(b,c));
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DPartition solver = new DPartition();
        solver.solve(1, in, out);
        out.close();
    }

    static class DPartition {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints(), m = in.ints();
            for (int i = (m + n) / n; i >= 1; i--) {
                if (m % i != 0 || m / i < n) {
                    continue;
                }
                out.println(i);
                return;
            }
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 23380
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[8] = {0,1,1,1,0,-1,-1,-1};
int dy[8] = {1,1,0,-1,-1,-1,0,1};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	vector<vector<char>> c(h+2, vector<char>(w+2, '.'));
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			cin >> c[i][j];
		}
	}
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			if(c[i][j] == '#'){
				cout << "#";
				continue;
			}
			int cnt = 0;
			rep(k,8){
				if(c[i+dy[k]][j+dx[k]] == '#') cnt++;
			}
			cout << cnt;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.function.BinaryOperator;
import java.util.function.UnaryOperator;
import java.io.PrintWriter;

public class Main {
    static int SIZE = 500001;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        int[] l = new int[q];
        int[] r = new int[q];
        for (int i = 0; i < q; i++) {
            l[i] = sc.nextInt() - 1;
            r[i] = sc.nextInt() - 1;
        }
        
        List<int[]>[] queries = new List[n];
        for (int i = 0; i < n; i++) {
            queries[i] = new ArrayList<int[]>();
        }
        for (int i = 0; i < q; i++) {
            queries[l[i]].add(new int[]{r[i], i});
        }
        
        List<Integer>[] rights = new List[n];
        for (int i = 0; i < n; i++) {
            rights[i] = new ArrayList<Integer>();
        }
        int[] last_app = new int[SIZE];
        Arrays.fill(last_app, -1);
        for (int i = 0; i < n; i++) {
            int num = array[i];
            if (last_app[num] != -1) {
                rights[last_app[num]].add(i);
            }
            last_app[num] = i;
        }
        
        BIT bit = new BIT(SIZE);
        
        int[] ans = new int[q];
        for (int i = n - 1; i >= 0; i--) {
            for (Integer right : rights[i]) {
                bit.add(right, 1);
            }
            
            for (int[] query : queries[i]) {
                int left = i;
                int right = query[0];
                int q_idx = query[1];
                ans[q_idx] = right - left + 1 - (int)bit.sum(right);
            }
        }
      
        PrintWriter out = new PrintWriter(System.out);
        for (Integer a : ans) {
            out.println(a);
        }
        out.flush();
        // for (Integer a : ans) {
        //     System.out.println(a);
        // }
    }
}

class BIT {
    int n;
    int[] d;

    // 単位元で埋めて新規作成
    public BIT(int n) {
        this.n = n;
        this.d = new int[n + 1];
    }
    
    public void add(int i, int x) {
        for (i++; i <= n; i += i&-i) {
            d[i] += x;
        }
    }
    
    public int sum(int i) {
        int x = 0;
        for (i++; i > 0; i -= i&-i) {
            x += d[i];
        }
        return x;
    }
    
    public int sum(int l, int r) {
        return sum(r-1) - sum(l-1);
    }
}

Measured memory_bytes: 174656
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <functional>
#include <iterator>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end())
#define PSort(x) sort(begin(x), end(x), pairCompare)
#define ll long long
#define INF 2000000000
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979
int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 };
using namespace std;

int w, h;

vector<vector<char>> v;
int ans = 0;

void dfs(int y,int x) {
	if (v[y][x] == '.') {
		v[y][x] = '#';
		ans++;
	}

	rep(i, 0, 4) {
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx && 0 <= ny&&nx < w&&ny < h&&v[ny][nx] == '.')dfs(ny, nx);
	}
}

int main(){
	while (1) {
		int sx, sy;
		cin >> w >> h;
		if (w == 0 && h == 0)break;
		v.resize(h, vector<char>(w));
		rep(i, 0, h) {
			rep(j, 0, w) {
				cin >> v[i][j];
				if (v[i][j] == '@') {
					sx = j;
					sy = i;
					v[i][j] = '.';
				}
			}
		}

		dfs(sy, sx);
		cout << ans << endl;

		v.clear();
		ans = 0;
	}


	

	return 0;
}

Measured memory_bytes: 3148
#include <iostream>
using namespace std;
int main(void){
    int K, S;
    int i, j;
    int c = 0;
    scanf("%d%d", &K, &S);
    for(i = 0; i <= K; i++){
        for(j = 0; j <= K; j++){
            if(S - i - j >= 0 && S - i - j <= K){
                c++;
            }
        }
        
    }
    printf("%d", c);
}


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

constexpr int p[4][3] = {{0, 1, 2}, {0, 3, 6}, {2, 5, 8}, {6, 7, 8}};

bool check(int front, int back, int k, vector<string>& s) {
    bool f = false, b = false;
    for(int i=0; i<3; ++i) {
        f |= s[front][p[k][i]] == '*';
        b |= s[back][p[k][i]] == '*';
    }
    return f && b;
}

int main() {
    string t;
    while(cin >> t, t != "#") {
        vector<string> v(6);
        v[0] += t;
        for(int i=0; i<6; ++i) {
            for(int j=0; j<3 - (i == 0); ++j) {
                string s;
                cin >> s;
                v[i] += s;
            }
        }
        for(int i=0; i<9; i += 3) {
            reverse(v[1].begin()+i, v[1].begin()+i+3);
            reverse(v[2].begin()+i, v[2].begin()+i+3);
        }
        for(int i=0; i<3; ++i) {
            swap(v[5][i], v[5][i+6]);
        }
        int res = 4;
        if(check(0, 2, 0, v)) {
            res = min(res, 2);
        }
        if(check(0, 2, 1, v)) {
            res = min(res, 1);
        }
        if(check(0, 2, 2, v)) {
            res = min(res, 1);
        }
        if(check(0, 2, 3, v)) {
            res = min(res, 0);
        }
        if(check(1, 3, 0, v)) {
            res = min(res, 3);
        }
        if(check(1, 3, 1, v)) {
            res = min(res, 2);
        }
        if(check(1, 3, 2, v)) {
            res = min(res, 2);
        }
        if(check(1, 3, 3, v)) {
            res = min(res, 3);
        }
        if(check(4, 5, 0, v)) {
            res = min(res, 1);
        }
        if(check(4, 5, 1, v)) {
            res = min(res, 2);
        }
        if(check(4, 5, 2, v)) {
            res = min(res, 2);
        }
        if(check(4, 5, 3, v)) {
            res = min(res, 1);
        }
        cout << res << endl;
    }
}


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

using namespace std;

int main()
{
    int i;
    int N;
    int K;

    cin >> N >> K;

    int L[N];
    for(i=0;i<N;i++)
    {
        cin >> L[i];
    }
    
    sort(L,L+N);

    int x = 0;
    for(i=N-1;i>N-K-1;i--)
    {
        x = x + L[i];
    }

    cout << x << endl;

    return 0;
}

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

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n)+1) : 1)
#define mem(x, val)    memset(x, val, sizeof(x))
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string str;
typedef pair<int, int> pii;


int main()
{
    THINK_TWICE_CODE_ONCE
    //freopen("test cases\\.txt", "r", stdin) ;
    string s; cin>>s;
    int n = s.size();
    for(int i =0; i<n; i++){
        if(i+1<n && s[i]==s[i+1])
            return cout<<i+1<<" "<<i+2, 0;
        if(i+2<n && s[i]==s[i+2])
            return cout<<i+1<<" "<<i+3, 0;
    }
    cout<<"-1 -1";
	return 0;

}


Measured memory_bytes: 512
#include<stdio.h>

int map[200][200],dp[200][200][400];
int h,w;

int search(int ax,int ay,int bx,int by){
  int i,c,max=0;
  if(ax==0 && ay==0){
    return map[0][0]+search(ax+1,ay,bx,by+1);
  }else if(ax==h-1 && ay==w-1){
    return map[h-1][w-1];
  }else{
    if(dp[ax][bx][ax+ay]==0){
    for(i=0;i<4;i++){
      if(ax+(i%2)<h && ay+(1-i%2)<w && bx+i/2<h && by+(1-i/2)<w){
        if((ax+(i%2)!=bx+(i/2)) || ax+ay==w+h-3){
        c=map[ax][ay]+map[bx][by]+search(ax+(i%2),ay+(1-i%2),bx+i/2,by+(1-i/2));
        if(c>max) max=c;
        }
      }
    }
    return dp[ax][bx][ax+ay]=max;
    }else{
      return dp[ax][bx][ax+ay];
    }
  }
}

int main(){
  int i,j,k;
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf("%d",&map[i][j]);
      for (k = 0; k < h+w; k++) {
        dp[i][j][k]=0;
        }
    }
  }
  printf("%d\n",search(0,0,0,0));
  return 0;
}


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

int main () {
	
	int n=0, i=0, x=0, res=0;
	vector <int> v;

	scanf("%d", &n);

	bool flag = 0;
	for (i=0; i<n; i++) {
		scanf("%d", &x);
		if (x%10 != 0) flag = 1;
		v.push_back(x);
		res += x;
	}

	sort(v.begin(), v.end());

	if (res%10 != 0) printf("%d\n", res);
	else {

		if (flag) {
			for (i=0; i<n; i++) {
				if (v[i]%10 != 0) {
					res -= v[i];
					break;
				}
			}
		}

		else res=0;

		printf("%d\n", res);

	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ga = sc.nextInt();
        int sa = sc.nextInt();
        int ba = sc.nextInt();
        int gb = sc.nextInt();
        int sb = sc.nextInt();
        int bb = sc.nextInt();

        int[] ab = new int[N+1];
        for(int i = 0; i<N+1; i++) {
            ab[i] = i;
        }
        if(N>1) ab[1] = 1;
        for(int i = 1; i<N+1; i++) {
            if(i-ga>=0) {
                ab[i] = Math.max(ab[i], ab[i - ga] + gb);
            }
            if(i-sa>=0) {
                ab[i] = Math.max(ab[i] , ab[i - sa] + sb);
            }
            if(i-ba>=0) {
                ab[i] = Math.max(ab[i] , ab[i - ba] + bb);
            }

        }

        int M = ab[N];
        //System.out.println(M);
        long[] btoa = new long[M+1];
        for(int i = 0; i<M+1; i++) {
            btoa[i] = i;
        }
        for(int i = 1; i<M+1; i++) {
            //btoa[i] = btoa[i-1]+1;
            if(i-gb>=0) {
                btoa[i] = Math.max(btoa[i], btoa[i - gb] + ga);
            }
            if(i-sb>=0) {
                btoa[i] = Math.max(btoa[i] , btoa[i - sb] + sa);
            }
            if(i-bb>=0) {
                btoa[i] = Math.max(btoa[i] , btoa[i - bb] + ba);
            }
        }
        System.out.println(btoa[M]);

    }
}

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

ll inf=9223372036854775806,ans=0;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,n,m,s=0,j,ans=0;
	bool q;
	string t;
	cin>>n;
	vector<string> a(n);
	for (i=0;i<n;i++){
		cin>>a[i];
	}
	cin>>m;
	vector<string> b(m);
	for (i=0;i<m;i++){
		cin>>b[i];
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	vector<pair<string,int>> g1;
	t=a[0];
	s=1;
	for (i=1;i<n;i++){
		if (t==a[i]){
			s++;
		}
		else {
			g1.push_back(make_pair(t,s));
			t.clear();
			t=a[i];
			s=1;
		}
	}
	g1.push_back(make_pair(t,s));
	vector<pair<string,int>> g2;
	t.clear();
	t=b[0];
	s=1;
	for (i=1;i<m;i++){
		if (t==b[i]){
			s++;
		}
		else {
			g2.push_back(make_pair(t,s));
			t.clear();
			t=b[i];
			s=1;
		}
	}
	g2.push_back(make_pair(t,s));
	for (i=0;i<g1.size();i++){
		q=false;
		for (j=0;j<g2.size();j++){
			if (g1[i].first==g2[j].first){
				ans=max(g1[i].second-g2[j].second,ans);
				q=true;
			}
		}
		if (q==false){
			ans=max(ans,g1[i].second);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import Data.List

main :: IO ()
main = do
  [n, t] <- getInts
  as <- getInts
  print $ solve as

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: [Int] -> Int
solve as = length $ filter (== maximum list) list
  where
    list = map fst $ drop 1 $ scanl (\(a1, a2) b -> (b - a2, min b a2))
      (1000000001, 1000000001) as


Measured memory_bytes: 36220
r, c = map(int, input().split())
l = []
for i in range(r):
    tmp_row = list(map(int, input().split()))
    l.append(tmp_row)

sum_colum = [0]*c
sum_matrix = 0
for i in range(r):
    sum_row = sum(l[i])
    sum_matrix += sum_row
    l_str = [str(n) for n in l[i]]
    print(" ".join(l_str),end=" ")
    print(sum_row,end="")
    print()

for i in range(c):
    for j in range(r):
        sum_colum[i]+= l[j][i]
    print(sum_colum[i], end=" ")
print(sum_matrix)



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

#define ll long long int

int main() {
ll a,b,n,size;
cin>>n>>a>>b;
if(n>=2&&a<b)
{
    size=n-2;
  cout<<(b-a)*(size)+1;    
}
else
 {
     if(a==b)
      {
      cout<<1;    
      }
      else
       {
     cout<<0;
       }
 }
	return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(c / (7 * a + b) * 7 + Math.min((c % (7 * a + b) + a - 1) / a, 7));
    }
}


Measured memory_bytes: 26416
N,M,K=map(int,input().split())
fac = [1]
mod = 998244353
for i in range(1,N+1):
    fac.append(fac[i-1]*i % mod)
ifac = [None]*(N+1)
ifac[-1] = pow(fac[N], mod-2, mod)
for i in range(N, 0, -1):
    ifac[i-1] = ifac[i]*i % mod
ans = 0
for k in range(K+1):
    t = M*fac[N-1] % mod
    t = t*ifac[N-1-k] % mod
    t = t*ifac[k] % mod
    t = t*pow(M-1,N-1-k, mod)
    t %= mod
    ans = (ans+t) % mod
print(ans)

Measured memory_bytes: 24668
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
// Range Query - RSQ and RAQ with Lazy Segment Tree
// https://www.slideshare.net/iwiwi/ss-3578491
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B

struct LazySegmentTree{
    // for vertex n
    // par (n-1)/2
    // chi 2n+1,2n+2

    // index i
    // bottom vertex n+i-1

    int segn2; // imply actually vertex number
    vector<ll> data,lazy; 
     
    LazySegmentTree(int n){
        segn2=1;
        while(segn2<n) segn2*=2; //必要分2^Mを取る
         
        data.resize(segn2*2,0);
        lazy.resize(segn2*2,0);
    }
    
    void eval(int k,int l,int r){
        if (lazy[k] != 0){ // lazy nonzero
            data[k] += lazy[k]; // itself
            
            if (r-l > 1){
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }

            lazy[k] = 0;
        }
    }

    ll query(int a,int b,int l=0,int r=-1,int k=0){
        if(r<0) r=segn2; // when calling function at first
        eval(k,l,r);

        if (r <= a || b <= l) return 0; //disjoint
        if (a <= l && r <= b) return data[k]; //include
        
        ll vl = query(a,b,l,(l+r)/2,k*2+1);
        ll vr = query(a,b,(l+r)/2,r,k*2+2);
        return vl+vr;
    }
     
    
    void update(int a,int b ,ll x, int l = 0, int r=-1,int k = 0){
        if(r==-1) r=segn2;

        eval(k,l,r);
        
        if (b <= l || r <= a) return;

        if (a <= l && r <= b){
            lazy[k] += (r-l) * x;
            eval(k,l,r);
        }else{
            //一部のみ含むとき，子ノードを計算してその結果をもらう
            update(a,b,x,l,(l+r)/2,2*k+1);
            update(a,b,x,(l+r)/2,r,2*k+2);
            data[k] = data[2*k+1] + data[2*k+2];
        }
        
    }
};

// 0-indexed
// sum [s,t) --> s,t+1
// update [s,t,x) --> s,t+1,x

int main(){
    int N,q;
    SCD2(N,q);
    LazySegmentTree seg(N);

    REP(i,q){
        int d; SCD(d);
        if (d==0){
            int s,t,x;
            SCD3(s,t,x);
            s--;t--;
            seg.update(s,t+1,x);
        }else{
            int s,t; SCD2(s,t);
            s--; t--;
            PRINTLLD(seg.query(s,t+1));
        }
    }
}



Measured memory_bytes: 7076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  string s,t;
  cin>>s>>t;
  int a=s.size(),b=t.size();
  int dp[3100][3100]={0};
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      if(s[i]==t[j])
     dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
      dp[i+1][j+1]=max({dp[i+1][j+1],dp[i+1][j],dp[i][j+1]});
    }
  }
  string r="";
  while(a>0&&b>0){
    if(dp[a][b]==dp[a][b-1]){
      b--;
    }else if(dp[a][b]==dp[a-1][b]){
      a--;
    }else{
      r+=s[a-1];
      a--;b--;
    }
  }
  reverse(r.begin(),r.end());
  cout<<r;
}

Measured memory_bytes: 37888
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N;
	cin >> N;
	map<string, LL> M;
	VLL check;
	vector<string> strings;
	for (LL n = 0; n < N; n++) {
		string S;
		cin >> S;
		auto itr = M.find(S);
		if (itr == M.end()) {
			M.insert(pair<string, LL>(S, check.size()));
			check.push_back(1);
			strings.push_back(S);
		}
		else {
			check[itr->second]++;
		}
	}
	LL MAX = 0;
	for (LL n = 0; n < check.size(); n++) {
		MAX = max(MAX, check[n]);
	}
	vector<string> ves;
	for (LL n = 0; n < check.size(); n++) {
		if (check[n] == MAX)ves.push_back(strings[n]);
	}
	sort(ves.begin(), ves.end(), [](string a, string b) {
		LL n = 0;
		for (; n < min(a.size(), b.size()); n++) {
			if (a[n] != b[n])break;
		}
		if (n == min(a.size(), b.size()))return a.size() < b.size();
		else return a[n] < b[n];
	});
	for (string& S : ves)cout << S << "\n";
	return 0;
}


Measured memory_bytes: 33564
#include<bits/stdc++.h>
using namespace std;
const int N=1000;
bool mark[N];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		int d;
		cin>>d;
		for(int j=1;j<=d;j++) {
			int x;
			cin>>x;
			mark[x]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(!mark[i]) ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

struct POINT {
	ll x1,y1,z1;
	ll x2,y2,z2;
	POINT(){}
	POINT(ll x1, ll y1, ll z1, ll x2, ll y2, ll z2):
	  x1(x1), y1(y1), z1(z1), x2(x2), y2(y2), z2(z2){};
};

int main(){
	ll n,k;
	cin >> n >> k;
	vector< ll > X,Y,Z;
	int memo[101][101][101];
	vector<POINT> p(n);
	for(int i=0;i<n;i++){
		int x1,y1,z1,x2,y2,z2;
		cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
		p[i] = POINT (x1,y1,z1,x2,y2,z2);
		X.push_back(x1); X.push_back(x2);
		Y.push_back(y1); Y.push_back(y2);
		Z.push_back(z1); Z.push_back(z2);
	}
	sort(X.begin(), X.end()); X.erase(unique(X.begin(), X.end()), X.end());
	sort(Y.begin(), Y.end()); Y.erase(unique(Y.begin(), Y.end()), Y.end());
	sort(Z.begin(), Z.end()); Z.erase(unique(Z.begin(), Z.end()), Z.end());
	for(int i = 0; i < n; i++){
	   int x1 = lower_bound(X.begin(), X.end(), p[i].x1) - X.begin();
	   int y1 = lower_bound(Y.begin(), Y.end(), p[i].y1) - Y.begin();
	   int z1 = lower_bound(Z.begin(), Z.end(), p[i].z1) - Z.begin();
	   int x2 = lower_bound(X.begin(), X.end(), p[i].x2) - X.begin();
	   int y2 = lower_bound(Y.begin(), Y.end(), p[i].y2) - Y.begin();
	   int z2 = lower_bound(Z.begin(), Z.end(), p[i].z2) - Z.begin();

	   for(int i = x1; i < x2; i++){
	     for(int j = y1; j < y2; j++){
	       for(int z = z1; z < z2; z++){
	         memo[i][j][z]++;
	       }
	     }
	   }
	 }
	 ll ret = 0;
	 for(int i = 0; i < 101; i++){
	   for(int j = 0; j < 101; j++){
	     for(int z = 0; z < 101; z++){
	       if(memo[i][j][z] >= k){
	         ret += (X[i + 1] - X[i]) * (Y[j + 1] - Y[j]) * (Z[z + 1] - Z[z]);
	       }
	     }
	   }
	 }
	 cout << ret << endl;
}

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

int main(int argc, char const *argv[])
{
    long a;
    cin >> a;
    while (true)
    {
        if (a <= 0)
        {
            break;
        }
        a -= 1000;
    }
    a = -a;
    cout << a << endl;

    return 0;
}


Measured memory_bytes: 3648
a,b,c = map(int,input().split())
ans = 0
while True:
    if a%2 ==1 or b%2 == 1 or c%2 == 1:
        ans = 0
        break
    ans+=1
    na = (b+c)//2
    nb = (c+a)//2
    nc = (a+b)//2
    if a == b and b == c:
        ans = -1
        break
    if na%2 == 1 or nb%2 == 1 or nc%2 == 1:
        break
    a,b,c, = na,nb,nc
print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if (a == b && b == c) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

const double PI=3.141592653589793;

// aaaaaaaaaaaaaaaa
void solve() {
  cout<<setprecision(15);

  int a,b,h,m;
  cin>>a>>b>>h>>m;
  double w=h+(m/60.0);
  double x=w*2*PI/12.0;
  double y=m*2*PI/60.0;
  double z=x-y;

  double ans=a*a+b*b-2*a*b*cos(z);
  ans=sqrt(ans);
  cout<<ans<<'\n';
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // int _; cin >> _; while(_--)
  solve();
	return 0;
}


Measured memory_bytes: 4172
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N, ans = 0;
  cin >> N;
  while (N > 0) {
    ans += N % 10;
    N /= 10;
  }
  if (ans == 1)
    cout << 10 << endl;
  else
    cout << ans << endl;
}

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

long long mod = 1000000007;
#define LOCAL 0
#define pb push_back
#define ll long long

ll po(ll a,ll b){
	ll x = 1,y=a;
	while(b>0){
		if(b%2){
			x = x*y;
			x %= mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}

//	Rolling Hash
long long po(long long a,long long b,long long mod){
	long long x = 1,y=a;
	while(b){
		if(b%2){
			x=x*y;
			x%=mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}

int prime1 = 29,prime2 = 31;
int mod1 = 1e9+7,mod2 = 1e9+9;
static long long po1[200005],ipo1[200005],po2[200005],ipo2[200005];

struct Hash{
	vector<pair<ll,ll> > hashed;
	Hash(string s){
		ll f = 0ll;
		ll f1 = 0ll;
		for(int i=0;i<s.length();i++){
			f += (po1[i] * (s[i]-'a'+1))%mod1;
			f1 += (po2[i] * (s[i]-'a'+1))%mod2;
			f %= mod1;
			f1 %= mod2;
			hashed.push_back(make_pair(f,f1));
		}
	}
	pair<ll,ll> query(int s,int e){
		pair<ll,ll> ans = hashed[e];
		if(s>0){
			ans.first -= hashed[s-1].first;
			ans.first += mod1;
			ans.first %= mod1;
			ans.second -= hashed[s-1].second;
			ans.second += mod2;
			ans.second %= mod2;
		}
		ans.first *= ipo1[s];
		ans.first %= mod1;
		ans.second *= ipo2[s];
		ans.second %= mod2;
		return ans;
	}
};

void pre(){
	po1[0] = po2[0] = ipo1[0] = ipo2[0] = 1ll;
	for(int i=1;i<=200000;i++){
		po1[i] = (po1[i-1]*prime1)%mod1;
		po2[i] = (po2[i-1]*prime2)%mod2;
		ipo1[i] = po(po1[i],mod1-2,mod1);
		ipo2[i] = po(po2[i],mod2-2,mod2); 
	}
}

int main(){
	pre();
	if(LOCAL){
    	freopen("C:/Users/gold/Desktop/sublime IO/input.txt","r",stdin);
    	freopen("C:/Users/gold/Desktop/sublime IO/output.txt","w",stdout);
	}
	int T = 1;
	//scanf("%d",&T);
	while(T--){
		static char str[200005],str1[200005];
		scanf("%s",str);
		int n = strlen(str);
		static int cnt[26];
		for(int i=0;i<n;i++){
			cnt[str[i]-'a']++;
		}
		long long ans = 1ll;
		int total = n;
		for(int i=0;i<n;i++){
			total--;
			cnt[str[i]-'a']--;
			ans += total - cnt[str[i]-'a'];
		}
		/*strcpy(str1,str);
		reverse(str1,str1+n);
		Hash a(str);
		Hash b(str1);
		long long ans = 1ll;
		int last1 = 0;
		static int dp[27][200005];
		for(int i=1;i<=n;i++){
			dp[str[i-1]-'a'][i]++;
			for(int j=0;j<26;j++){
				dp[j][i] += dp[j][i-1];
			}
		}

		for(int i=0;i<n;i++){
			int lo = i,high = n-1;
			int last = i;
			while(lo <= high){
				int mi = (lo+high)>>1;
				if(a.query(i,mi) == b.query(n-1-mi,n-1-i)){
					last = mi;
					lo = mi + 1;
				} else {
					high = mi - 1;
				}
			}
			last1 = max(last1,last);
			long long rem = n - 1 - last - dp[str[i]-'a'][n] + dp[str[i]-'a'][last+1];
			printf("%d %d %lld %d\n",i,last,rem,dp[str[i]-'a'][n] - dp[str[i]-'a'][last+1]);
			ans += rem;
		}*/
		printf("%lld\n",ans);
	}
	return 0;	
}

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

using namespace std;

int main(){
    int n,T;
    int ans=10000;
    cin>>n>>T;
    for(int i=0;i<n;i++){
        int c,t;
        cin>>c>>t;
        if(t<=T){
            ans=min(ans,c);
        }
    }
    if(ans==10000) cout<<"TLE"<<endl; else cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

ll h,w;
bool uni[444][444];
ll ans = 0;
string s[444];
ll kuro = 0,siro = 0;
void check(int x,int y) {
	if (uni[x][y]) return;
	// bool a[444][444];
	uni[x][y] = true;
	if (s[x][y] == '.') {
		siro++;
	} else {
		kuro++;
	}
	for (int i = 0;i < 4;i++) {
		if (y+dy[i] >= w || y+dy[i] < 0 || x+dx[i] >= h || x+dx[i] < 0 || uni[x+dx[i]][y+dy[i]] || s[x+dx[i]][y+dy[i]] == s[x][y]) continue;
   		check(x+dx[i],y+dy[i]);
   	}
	return;
}

int main() {
	cin >> h >> w;
	for (int i = 0;i < h;i++) {
		cin >> s[i];
	}
	for (int i = 0;i < 444;i++) {
		for (int j = 0;j < 444;j++) {
			uni[i][j] = false;
		}
	}
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			check(i,j);ans+=kuro*siro;kuro = 0;siro = 0;
		}
	}
	// for (int i = 0;i < 444;i++) {
	// 	for (int j = 0;j < 444;j++) {
	// 		if (uni[i][j]) cout << "1" << " ";
	// 		else cout << "2" << " ";
	// 	}
	// 	cout << endl;
	// }
	cout << ans << endl;
}

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



int main() {
    int n;
    cin >> n;
    
    map<string,int> m;
    vector<string> s(n);
    rep(i,n) {
        cin >> s[i];
        m[s[i]]++;
    }
    
    sort(s.begin(), s.end());
    
    int ma = 0;
    rep(i,n) {
        //cout << s[i] << endl;
        if(ma < m[s[i]])
            ma = m[s[i]];
    }
    
    string ans = "";
    rep(i,n) {
        if(ma == m[s[i]] && ans != s[i]) {
            ans = s[i];
            cout << ans << endl;
        }
    }
    
    
    
    return 0;
}




Measured memory_bytes: 25148