akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class A {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            char c[] = in.next().toCharArray();
            int r = 0, max = 0;
            for (int i = 0; i < 3; ++i) {
                if (c[i] == 'R') r++;
                else {
                    max = Math.max(r, max);
                    r = 0;
                }
            }
            max = Math.max(r, max);
            out.println(max);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32428
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;} 
int lcm(int a,int b){return a/gcd(a,b)*b;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;
    cin >> x >> y;
    if(x == 0 && y == 0) cout << 0 << '\n';    
    else if(x == 0){ 
        if(y < 0) cout << abs(y) + 1 << '\n';
        else cout << y << '\n';
    }   
     else if(y == 0){ 
         if(x < 0) cout << abs(x) << '\n';
         else cout << x + 1 << '\n';
    }   
    else if(abs(x) < abs(y)){
        if(x > 0 && y > 0) cout << y - x << '\n';
        else if(x < 0 && y > 0) cout << y - abs(x) + 1 << '\n';
        else if(x > 0 && y < 0) cout << min(abs(y) - x + 1,abs(y) + x) << '\n';
        else if(x < 0 && y < 0) cout << abs(y) - abs(x) + 2 << '\n';
    }   
    else if(abs(x) > abs(y)){
        if(x > 0 && y > 0) cout << x - y + 2 << '\n';
        else if(x < 0 && y > 0) cout << min(abs(x) + y,abs(x) - y + 1) << '\n';
        else if(x > 0 && y < 0) cout << x - abs(y) + 1 << '\n';
        else if(x < 0 && y < 0) cout << abs(x) - abs(y) << '\n';
    }   
    else if(abs(x) == abs(y)){
        if(x > 0 && y > 0) cout << 0 << '\n';
        else if(x < 0 && y > 0) cout << 1 << '\n';
        else if(x > 0 && y < 0) cout << 1 << '\n';
        else if(x < 0 && y < 0) cout << 0 << '\n';
    }   
    return 0;
}


Measured memory_bytes: 256
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<ll,ll> PII;
typedef vector<ll> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+5;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll n;
void solve(){
	cin>>n; 
	ll x = n/500;
	ll y = (n%500)/5;
	cout<<1000*x+5*y;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}




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


void solve(long long N){
    string res = "";
    while (N)
    {
        --N;
        res += (char)('a' + (N % 26));
        //cout << "N:" << N << ", res:" << res << endl;
        N /= 26;
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}


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

  string str ; cin >> str ;
  str[3]='8' ;
  cout << str << endl;
  
  return 0;
}


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

using namespace std;

int main()
{
    int n;

    cin>>n;

    int stones[n];

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

    int dp[n];

    dp[0]=0;

    dp[1]=abs(stones[1]-stones[0]);

    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(stones[i]-stones[i-1]), dp[i-2]+abs(stones[i]-stones[i-2]));
    }

    cout<<dp[n-1];

    return 0;
}

Measured memory_bytes: 4376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String string = sc.nextLine();
		char[] str_char = new char[3];
		for (int i = 0; i < 3; i++) {
			str_char[i] = string.charAt(i);
		}

		if (str_char[1] == 'B') {
			str_char[1] = 'R';
		} else {
			str_char[1] = 'B';
		}

		System.out.println(str_char);
	}
}

Measured memory_bytes: 35664
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(ll i=a;i<b;++i)
#define dloop(i,a,b) for(ll i=a;i>=b;--i)
#define all(a) a.begin(),a.end()
#define lar 1000000007
#define pq priority_queue
#define pll pair<ll,ll>
#define ss second
#define ff first
#define pb push_back
#define ppb pop_back
#define umap unordered_map
#define ub upper_bound
#define lb lower_bound
#define br "\n"
#define sp " "
const int N=2e5+1;
ll arr[N];
ll par[N];
ll rnk[N];
ll fnd(ll a)
{
    if(a==par[a]) return a;
    par[a] = fnd(par[a]);
    return par[a];
}

void uni(ll a,ll b)
{
    ll x = fnd(a);
    ll y = fnd(b);
    if(x!=y)
    {
        if(rnk[x]>rnk[y]) par[y]=x;
        else if(rnk[x]<rnk[y]) par[x]=y;
        else { par[y]=x; rnk[x]++;}
    }
}
void solve(){
	ll n,m;
	cin>>n>>m;
	loop(i,1,n+1)
	{
	    par[i]=i;
	    rnk[i]=1;
	}
	loop(i,0,m)
	{
        ll a,b;
        cin>>a>>b;
        uni(a,b);
	}
	loop(i,1,n+1)
	{
        arr[fnd(i)]++;
	}
	ll ans=0;
	loop(i,1,n+1)
	{
	    ans = max(ans,arr[i]);
	}
	cout<<ans<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 8260
using System;
class A
{
    static void Main()
    {
        string a = "";
        string s = Console.ReadLine();
        for (int i = 0; i < s.Length; i++)
        {
       //     string y = s.Substring(i, 1);
            if (s[i] != 'B') { a +=s[i]; }
            else { if (!string.IsNullOrEmpty(a)) { a=a.Substring(0,a.Length -1 ); } }
        }
        Console.WriteLine(a);
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <tr1/unordered_set>
using namespace std;

int n , v[20] , ans = 0;

tr1::unordered_set<int> memo[20];

int X[421] , Y[421] , top;
 
int main(){
	while(scanf("%d\n",&n)&& n){
		int dp2[21] = {0};
		for(int i = 0 ; i < n ; i++) scanf("%d",&v[i]) , memo[i].clear();
		for(int i = n-1 ; i >= 0 ; i--) dp2[i] = dp2[i+1] + v[i];
		ans = 99999999;
		top = 0;
		X[top] = 0;
		Y[top] = 0;
		while(~top){
			int pos = X[top] , sum = Y[top]; top--;
			if(pos==n) ans = min(ans,sum);
			else{
				if( sum >= dp2[pos] && ans <= sum-dp2[pos]  ) continue;
				X[++top] = pos+1;
				Y[top]   = sum+v[pos];
				X[++top] = pos+1;
				Y[top]   = abs(sum-v[pos]);
			}
		}
		printf("%d\n",ans);
	}
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll N;
vector<ll> A;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  cin >> N;
  A.resize(N);
  vector<ll> v(N);
  ll ans = 0;
  rep(i, N) {
    cin >> A[i];
    if (i + A[i] < N) v[i+A[i]]++;
    if (i - A[i] > 0) ans += v[i-A[i]];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6368
import java.util.Scanner;

public class Main {

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

		for(int i = 0;i < a;i++){
			n[i] = sc.nextInt();
		}

		for(int j = 0;j < a;j++){
			if(n[j] >= b){
				count++;
			}
		}

		System.out.println(count);

	}

}


Measured memory_bytes: 50008
#include <bits/stdc++.h>
using namespace std;
const int M=2e5+10;
map<string,int> mp,vis;
string ss[M];
vector<string> ans;
int main(int argc, char const *argv[])
{
	int n;cin>>n;
	for(int i=0;i<n;i++){
		string s;cin>>s;
		ss[i]=s;
		mp[s]++;
	}
	int mx=-1;

	for(int i=0;i<n;i++){
		mx=max(mx,mp[ss[i]]);
	}

	for(int i=0;i<n;i++){
		if(mp[ss[i]]==mx && vis[ss[i]]==0){
			ans.push_back(ss[i]);
			vis[ss[i]]=1;
		}
	}
	sort(ans.begin(),ans.end());
	for(int i=0;i<(int)ans.size();i++)cout<<ans[i]<<endl;
	return 0;
}

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

using namespace std;

int main(){
  int a,b;
  string s1,s2;
  cin>>s1>>s2;
  cin>>a>>b;
  string s;
  cin>>s;
  if(s==s1){
    a--;
  }
  if(s==s2){
   b--;
  }
  cout<<a<<" "<<b;
  
  return 0;
  
  
  
}

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

int main() {
    double pi = 3.1415926535897932384;
    double A, B;
    cin >> A >> B;
    double H, M;
    cin >> H >> M;
    double x1, y1, x2, y2;
    double ang1 = (double)(H*60+M)/(12*60)*2*pi, ang2 = (double)M/60*2*pi;
    x1 = A*cos(ang1);
    y1 = A*sin(ang1);
    x2 = B*cos(ang2);
    y2 = B*sin(ang2);
    cout << setprecision(15) << hypot(x2-x1, y2-y1) << endl;
    return 0;
}

Measured memory_bytes: 4100
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

vector<int> data;

int main(){
	REP(i,10){
		int tmp;
		cin >> tmp;
		data.pb(tmp);
	}
	sort(All(data));
	cout << data[9] << endl;
	cout << data[8] << endl;
	cout << data[7] << endl;
	return 0;
}

Measured memory_bytes: 1220
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true){
      int a = sc.nextInt();
      int b = sc.nextInt();
      if ( a == 0 && b == 0){ break; }
      for (int i = 1; i <= a; i++) {
        for (int j = 1; j <= b; j++){
          System.out.print("#");
        }
        System.out.print("\n");
      }
      System.out.print("\n");
    }
  }
}



Measured memory_bytes: 37920
import math
a, b, x = map(int, input().split())

s = x / a

if s * 2 >= a * b:
  k = (2 * a * b - 2 * s) / a
  r = math.atan(k / a)
  print(math.degrees(r))

else:
  k = (2 * s) / b
  r = math.atan(b / k)
  print(math.degrees(r))

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

namespace AtCorder
{
	public class Program
	{	
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int w = cin.Int();
			int h = cin.Int();
			int x = cin.Int();
			int y = cin.Int();

			double d = (long)w * h / 2.0;
			int multi = 0;
			if (x == w / 2.0 && y == h / 2.0) {
				multi = 1;
			}

			Console.WriteLine($"{d} {multi}");
		}
		
		
	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


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

if x > 0:
    if x < k * d:
        if x // d % 2 == k % 2:
            g = x % d
        else:
            g = abs(d - (x % d))
    else:
        g = x - k * d
elif x == 0:
    if k % 2:
        g = d
    else:
        g = 0
else:
    if abs(x) < k * d:
        if abs(x) // d % 2 == k % 2:
            g = abs(x) % d
        else:
            g = abs(d - (abs(x) % d))
    else:
        g = abs(x) - k * d

print(g)


Measured memory_bytes: 9208
N,A,B = map(int,input().split())
h = []
for _ in range(N):
    h.append(int(input()))
h.sort(reverse=True)
def judge(M):
    i = 0
    j = M
    while True:
        if i >= N:
            return(True)
        if h[i] <= M*B:
            return(True)
        diff = h[i] - M*B
        needs = diff//(A-B)
        if diff%(A-B) != 0:
            needs += 1
        #need better/shorter impl
        j -= needs
        if j < 0:
            return(False)
        i += 1
#Binary search on the answer
ok = N*10**9
ng = 0
while ok > ng + 1:
    mid = (ok+ng)//2
    if judge(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Measured memory_bytes: 7508
n,a,b = map(int,input().split())
s = input()
passed = 0
forign = 0
for i in range(len(s)):
    if s[i] =="a" and passed <a+b:
        print("Yes")
        passed += 1
    elif s[i] == "b" and passed < a+b and forign <b:
        print("Yes")
        passed += 1
        forign += 1
    else:
        print("No")


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

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(){
	int r,c;
	cin >> r >> c;
	int tbl[r][c];

	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < c; ++j) {
			cin >> tbl[i][j];
		}
	}
	int sums[c+1];
	for (int i = 0; i < c+1; ++i) {
		sums[i]=0;
	}

	for (int i = 0; i < r; ++i) {
		int rsum=0;
		for (int j = 0; j < c; ++j) {
			sums[j] += tbl[i][j];
			sums[c] += tbl[i][j];
			rsum += tbl[i][j];
			cout << tbl[i][j] << " ";
		}
		cout << rsum << endl;
	}
	for (int i = 0; i < c; ++i) {
		cout << sums[i] << " ";
	}
	cout << sums[c] << endl;


	return 0;
}



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

using namespace std;

std::pair<int64_t, int64_t> solve(int64_t a, int64_t b, int64_t k) {
  while (k != 0) {
    if ((a % 2) != 0) {
      a--;
    }
    b += a / 2;
    a /= 2;
    k--;
    if (k == 0) {
      break;
    }
    if ((b % 2) != 0) {
      b--;
    }
    a += b / 2;
    b /= 2;
    k--;
  }
  return std::make_pair(a, b);
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t a;
  std::cin >> a;
  int64_t b;
  std::cin >> b;
  int64_t k;
  std::cin >> k;
  auto const res = solve(a, b, k);
  std::cout << res.first << " " << res.second << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>

using namespace std;

#define fo(i,n) for(int i=0; i<(int)n; i++)
#define rep(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define pii pair<int,int>

int n,m;
struct point{
	double x,y;
	point(int x=0, int y=0): x(x),y(y){}
};
vector<point> xy,xz;
vector<int> xs;

double area(double x, vector<point> &v) {
	double lo = 100000;
	double hi = -100000;
	
	for (int i=0; i<v.size(); i++) {
		double x1 = v[i].x;
		double x2 = v[(i+1)%v.size()].x;
		double y1 = v[i].y;
		double y2 = v[(i+1)%v.size()].y;
		
		if ((x-x2)*(x-x1)<=0) {
			double m = (x-x1)/(x2-x1);
			double yy = m*(y2-y1) + y1;
			
			hi = max(hi, yy);
			lo = min(lo, yy);
		}
	}

	return (hi-lo);
}

int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

	while (scanf("%d%d",&m,&n) && n!=0) {
		xy.clear();
		xz.clear();
		xs.clear();

		int minim = 100000, maxim = -10000;
		int tm = 1000000, tma = -1000000;
		for (int i=0; i<m; i++) {
			int a,b;
			scanf("%d%d",&a,&b);
			xy.push_back(point(a,b));
			xs.push_back(a);
			tm = min(tm,a);
			tma = max(tma, a);
		}
		minim = tm;
		maxim = tma;
		tm = 1000000;
		tma = -100000;
		for (int i=0; i<n; i++) {
			int a,b;
			scanf("%d%d",&a,&b);
			xz.push_back(point(a,b));
			xs.push_back(a);
			tm = min(tm,a);
			tma = max(tma, a);
		}
		minim = max(minim,tm);
		maxim = min(maxim, tma);
		
		sort(xs.begin(),xs.end());
		xs.erase(unique(xs.begin(),xs.end()),xs.end());
		
		double vol = 0.0;
		
		for (int i=0; i<xs.size()-1; i++) {
			if (xs[i]>=minim && xs[i]<=maxim && xs[i+1]>=minim && xs[i+1]<=maxim) {
				double l = xs[i];
				double r = xs[i+1];
				double mid = (l+r)/2;
				
				double a1 = area(l,xz)*area(l,xy);
				double a2 = area(r,xz)*area(r,xy);
				double a3 = area(mid,xz)*area(mid,xy);
				
				vol += (r-l)*(a1 + a2 + a3*4.0) / 6.0;
			}
		}
		
		printf("%.12lf\n",vol);
	}

    return 0;

}

Measured memory_bytes: 1244
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;

	void doIt() {
		int N = sc.nextInt();
		int A[] = new int[N];
		long cnt[] = new long[N + 1];
		Set<Integer> set = new HashSet<>();
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			cnt[A[i]]++;
			set.add(A[i]);
		}
		long sum = 0;
		for(int i : set) {
			sum += (cnt[i] * (cnt[i] - 1))/2;
		}
		for(int i = 0; i < N; i++) {
			long ans = sum;
			ans -= (cnt[A[i]] * (cnt[A[i]] - 1))/2;
			ans += ((cnt[A[i]] - 1) * (cnt[A[i]] - 2))/2;
			System.out.println(ans);
		}
		
		
	}

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

}


Measured memory_bytes: 107404
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int N,A,B,ans;
    string S;
    bool F=true;
int main(){
    cin>>A>>B;

    cout<<(A+B+1)/2<<endl;
    return 0;

}

Measured memory_bytes: 256
k = int(input())

a = 1
b = 1

def snk(n):
    s = 0
    for i in str(n):
        s += int(i)
    return n / s

for _ in range(k):
    print(a)
    if snk(a + 10 ** (b -1)) > snk(a + 10 ** b):
        b += 1
    a += 10 ** (b-1)


Measured memory_bytes: 3060
#include <cstdio>
using namespace std;
const int M=10,MQ=50;
int w[M+5],a[MQ+5],b[MQ+5],c[MQ+5],d[MQ+5];
int n,m,q,ans;
void dfs(int x,int y){
	if(x>m){
		int A[M+5]={0};
		for(int i=1;i<=m;++i){
			A[w[i]]++;
		}
		int sum=0,cnt=0;
		for(int i=0;i<=n;++i){
			int t=A[i];
			A[i]=sum;
			sum+=t;
		}
		for(int i=1;i<=q;++i){
			if(A[b[i]]-A[a[i]]==c[i])cnt+=d[i];
		}
		ans=(cnt>ans?cnt:ans);
		return;
	}
	for(int i=y;i<=n;++i){
		w[x]=i;
		dfs(x+1,i);
	}
}
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=q;++i){
		scanf("%d%d%d%d",a+i,b+i,c+i,d+i);
	}
	w[1]=0;
	dfs(2,1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1732
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))

ans = 0
count = 0
for i in range(n):
    if a[i] < 0:
        a[i] = -a[i]
        count += 1

ans = sum(a)
if count % 2 == 0:
    print(ans)
else:
    print(ans - min(a) * 2)


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    vector<long long> sum(N);
    sum[0] = A[0];
    for (int i = 1; i < N; i++)
        sum[i] = sum[i - 1] + A[i];

    long long s = sum[N - 1];
    long long res = 1e+18;
    for (int i = 0; i < N - 1; i++)
        res = min(res, abs(s - 2 * sum[i]));

    cout << res << endl;
    return 0;
}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void solve(long long N, long long K, std::vector<long long> A) {
  int c[64][2] = {};
  for(int i = 0 ; i < A.size() ; i++){
    for(int j = 0 ; j < 60 ; j++){
      c[j][A[i] >> j & 1]++;
    }
  }
  ll x = 0;
  for(int i = 59 ; i >= 0 ; i--){
    if( c[i][0] > c[i][1] && (x|(1ll<<i)) <= K ){
      x |= (1ll<<i);
    }
  }
  ll sum = 0;
  for(int i = 0 ; i < A.size() ; i++){
    sum += A[i] ^ x;
  }
  cout << sum << endl;
}


int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, K, std::move(A));
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;

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


int main() {
  int N, A, B;
  string S;
  cin >> N >> A >> B >> S;
  int pass = 0;
  int passb =0;
  rep(i,S.size()){
    if (S[i] == 'b') passb++;
    if(S[i] == 'a' && pass < A + B ){
      pass++;
      cout << "Yes" << endl;
    } else if (S[i] == 'b' && pass < A + B && passb <= B) {
      pass++;
      cout << "Yes" << endl;  
    } else{
      cout << "No" << endl;
    }
  }


	return 0;
}



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

int n,t,m[1000],l[1000],k[1000];

bool check(int x){
  int c[1001]={},used[1000]={},cnt=n;
  for(int i=0;i<t&&cnt;i++){
    x+=c[i];
    for(int j=0;j<n&&x;j++){
      if(used[j])continue;
      if(i+m[j]>t)return 0;
      if(i%(l[j]+k[j])<=l[j])c[i+m[j]]++,cnt--,used[j]=1,x--;
    }
  }
  return !cnt;
}

int main(){
  while(scanf("%d%d",&n,&t),n){
    for(int i=0;i<n;i++)scanf("%d%d%d",&m[i],&l[i],&k[i]);
    int ans=0;
    for(int i=1;i<=n&&!ans;i++)if(check(i))ans=i;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3164
N = int(input())
sol = [0 for _ in range(N)]

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            v = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + x * z
            if v > N:
                break
            else:
                sol[v - 1] += 1

for i in range(N):
    print(sol[i])

Measured memory_bytes: 9316
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int dp[2001][6001];
int main() {
    int N,MOD;
    cin >> N >> MOD;

    int i,j;
    for (i = 0; i < 3*N; i++) dp[0][i] = 1;
    for (i = 1; i <= N; i++) {
        dp[i][0] = 1;
        for (j = 0; j <= 3*N; j++) {
            if (j > 0) dp[i][j] = dp[i][j-1];
            if (j > 1) dp[i][j] += ((LLI) dp[i-1][j-2]*(j-1)) % MOD,dp[i][j] %= MOD;
            if (j > 2) dp[i][j] += ((LLI) dp[i-1][j-3]*((j-1)*(j-2))) % MOD,dp[i][j] %= MOD;
        }
    }
    cout << dp[N][3*N] << endl;

    return 0;
}



Measured memory_bytes: 47104
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール

// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll w, h; cin >> w >> h;
    vector<ll> p(w), q(h);
    REP(i, w) cin >> p[i];
    REP(i, h) cin >> q[i];

    const int HORIZONTAL = 0;
    const int VERTICAL   = 1;
    vector<tuple<ll, ll, ll>> rank; rank.reserve(w+h);
    REP(i, w) rank.emplace_back(p[i], i, HORIZONTAL);
    REP(i, h) rank.emplace_back(q[i], i, VERTICAL);
    sort(ALL_OF(rank));

    ll xd = w+1, yd = h+1;
    ll ans = 0;
    for (auto &pv : rank) {

        ll cost, pos, type;
        tie(cost, pos, type) = pv;

        if (type == HORIZONTAL) {
            xd--;
            ans += yd * cost;
        } else if (type == VERTICAL) {
            yd--;
            ans += xd * cost;
        }

    }

    cout << ans << endl;

}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define INF 2e9

#define REP(i,n) for(int i = 0; i < n;++i)
#define REPA(i,a,n) for(int i = a; i < n; ++i)
#define ALL(a) a.begin, a.end()

using namespace std;

int main(void) {

	int N, count = 0, max = 0;

	cin >> N;

	vector<int> H(N);

	REP(i, N) cin >> H[i];

	for (int i = N - 1; i > 0; i--) {
		if (H[i] <= H[i - 1]) count++;
		else {
			if (max < count) max = count;
			count = 0;
		}
	}

	if (max == 0) max = count;
	cout << max << '\n';

	return 0;
}

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

int main(){
  int a,b,c,d,res;
  char s[300100];
  int e[300100],w[300100];
  int num;
  cin >> num;
    a=num/1000;
    num%=1000;
    b=num/100;
    num%=100;
    c=num/10;
    num%=10;
    d=num;
  int op1,op2,op3;
  for(int p=0;p<=1;p++){
    for(int q=0;q<=1;q++){
      for(int r=0;r<=1;r++){
          if(p==0)res=a+b;
          else res=a-b;
          if(q==0)res+=c;
          else res-=c;
          if(r==0)res+=d;
          else res-=d;
          if(res==7){
            op1=p;
            op2=q;
            op3=r;
            break;
          }
        }
      }
    }
    cout << a << flush;
    if(op1==0)cout << "+" << flush;
    else cout <<'-' << flush;
    cout << b <<flush;
    if(op2==0)cout << '+' << flush;
    else cout <<'-' << flush;
    cout << c <<flush;
    if(op3==0)cout << '+' << flush;
    else cout <<'-' << flush;
    cout << d << '=' << 7 <<endl;
}


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

int main(){
  unsigned short *A, *B;
  int n, i, j;
  int C[VMAX+1];

  scanf("%d", &n);
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

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

     return 0;
}


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

using namespace std;

#define N 800000

int n,ans,pre[N],suf[N];
char s[N];

int main(){
	scanf("%d%s",&n,s+1);
	for (int i=1;i<=n;++i) pre[i]=pre[i-1]+(s[i]=='W');
	for (int i=n;i>=1;--i) suf[i]=suf[i+1]+(s[i]=='E');
	ans=n; for (int i=1;i<=n;++i) ans=min(ans,pre[i-1]+suf[i+1]); 
	printf("%d\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 5760
import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    N = int(input())
#    A, B, C = map(int,input().split())
#    S = input()
    if N < 1200:
        print("ABC")
    elif N < 2800:
        print("ARC")
    else:
        print("AGC")
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;



void solve(){
			int a,b,c;
			cin>>a>>b>>c;
			int x=a*100+b*10+c;
			if(x%4==0)cout<<"YES";
			else cout<<"NO";

}

int main(){
	Red;
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
class SegTree():
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.func = function
        self.basement = basement
        self.seg = [basement]*(2**(self.K+1))
        X=2**self.K
        for i,v in enumerate(lists):
            self.seg[i+X-1] = v

        for i in range(2*X-2, 0, -2):
            self.seg[(i-1)>>1] = self.func(self.seg[i], self.seg[i-1])

    def update(self, k, value):

        X=2**self.K
        k += X-1
        self.seg[k] = value
        while k:
            k = (k-1)>>1
            self.seg[k] = self.func(self.seg[(k<<1)+1], self.seg[(k<<1)+2])

            

    def query(self, p, q):
        if q <= p:
            return self.basement
        num = 2**self.K
        p += num-1
        q += num-2
        res = self.basement
        while q-p > 1:
            if p & 1 == 0:
                res = self.func(res, self.seg[p])
            if q & 1 == 1:
                res = self.func(res, self.seg[q])
                q -= 1
            p = p>>1
            q = (q-1)>>1
        if p == q:
            res = self.func(res, self.seg[p])
        else:
            res = self.func(self.func(res, self.seg[p]), self.seg[q])
        return res

import sys
input=sys.stdin.readline

N=int(input())
S=list(input())
Q=int(input())
que=[tuple(input().split()) for i in range(Q)]
alpha="abcdefghijklmnopqrstuvwxyz"
Data={alpha[i]:[0]*N for i in range(26)}
for i in range(N):
    Data[S[i]][i]+=1
SEG={alpha[i]:SegTree(Data[alpha[i]],max,0) for i in range(26)}
for X,u,v in que:
    if X=="1":
        u=int(u)-1
        NOW=S[u]
        S[u]=v
        SEG[NOW].update(u,0)
        SEG[v].update(u,1)
    else:
        u,v=int(u)-1,int(v)-1
        res=0
        for j in range(26):
            res+=SEG[alpha[j]].query(u,v+1)
        print(res)
            
        
    
    


Measured memory_bytes: 391728
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main() {
  int N; cin >> N;
  vector<long long> A(N);
  int sgn = 0;
  for(int i=0; i < N; ++i){
    cin >> A[i];
    if(A[i] < 0){
      sgn += 1;
    }
  }
  vector<long long> ABS(N);
  for(int i=0; i < N; ++i){
    ABS[i] = abs(A[i]);
  }
  long long ans = 0;
  for(int i=0; i < N; ++i){
    ans += ABS[i];
  }
  if(sgn%2 != 0){
    long minim = *min_element(ABS.begin(), ABS.end());
    ans -= 2 * minim;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int64_t>
#define si             set<int>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    int n,c=0;cin>>n;
    int a[n];
    for(auto &x:a) cin>>x,--x;
    for(int i=0;i<n;++i)
    {
    	if(a[i]==-1) continue;
    	if(a[a[i]]==i){
    		c++;
    		a[a[i]]=-1;
    		a[i]=-1;
    	}
    }
    cout<<c;
}
    


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

int main(){

    while(1){
        int n; cin >> n;
        if(!n) break;

        vector<string> ss(n);
        for(int i = 0; i < n; i++) cin >> ss[i];

        int d = 0;
        for(int i = 0; i < n; i++){
            d = max(d, (int)ss[i].size() - 1);
        }

        vector<vector<int> > s(n);
        for(int i = 0; i < n; i++){
            for(int j = 0; j < (int)ss[i].size(); j++){
                if(ss[i][j] == '.') s[i].push_back(-1);
                else if(ss[i][j] == '+') s[i].push_back(-2);
                else if(ss[i][j] == '*') s[i].push_back(-3);
                else s[i].push_back((int)(ss[i][j] - '0')); 
            }
        }

        //cout << max_d << endl;

        while(d > 0){

            int state = 0;                  //0 := 何もしない  1 := 足し算をする  2 := 掛け算をする
            int idx;
            int res;
            //d-1を見ていく
            
            for(int i = 0; i < n; i++){
                
                if(state == 0){
                    if((int)s[i].size() < d) continue;
                    else if(s[i][d - 1] == -2){
                        state = 1;
                        idx = i;
                        res = 0;
                    }else if(s[i][d - 1] == -3){
                        state = 2;
                        idx = i;
                        res = 1;
                    }
                }else{

                    if((int)s[i].size() < d){
                        s[idx][d - 1] = res;
                        state = 0;
                    }else if(s[i][d - 1] == -1){
                        //計算する
                        if(s[i][d] == -1) continue;

                        if(state == 1) res += s[i][d];
                        else res *= s[i][d];
                    }else if(s[i][d - 1] == -2){
                        s[idx][d - 1] = res;
                        state = 1;
                        idx = i;
                        res = 0;
                    }else if(s[i][d - 1] == -3){
                        s[idx][d - 1] = res;
                        state = 2;
                        idx = i;
                        res = 1;
                    }
                }
            }

            if(state != 0){
                s[idx][d - 1] = res;
                state = 0;
            }
            d--;
        }

        /*for(int i = 0; i < n; i++){
            cout << s[i] << endl;
        }*/

        cout << s[0][0] << endl;
    }
}


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

using namespace std;

struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i=0;i<N;++i) par[i] = i;
    }

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

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

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

    int uni(){
        sort(par.begin(), par.end());
        par.erase(unique(par.begin(), par.end()), par.end());
        return par.size();
    }
};

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

    UnionFind tree(n);
    for(int i=0;i<m;++i){
        int x, y, z;
        cin >> x >> y >> z;
        tree.unite(x-1, y-1);
    }

    int cnt = 1;
    for(int i=0;i<n;++i){
        if(!tree.same(0, i)){
            tree.unite(0, i);
            ++cnt;
        }
    }
    cout << cnt << endl;

    return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int a, b, c;
	cin >> a >> b >> c;

	for(int i=a; i<=a*b; i+=a){
		if(i % b == c){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	
	return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;
#define rep(i,s,e) for(ll i = (int)(s); i < (int)(e); ++i)
#define per(i,s,e) for(ll i = (int)(s)-1; i >= (int)(e); --i)

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;

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

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

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

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

template<long long mod>
class modint{
private:
  long long num;
  long long extgcd(long long a, long long b, long long&x, long long&y)const {
    long long d = a;
    if(b != 0){d = extgcd(b, a%b, y, x);  y -= (a/b) * x;}
    else{x = 1; y = 0;}
    return d;
  }
  long long modinverse()const{
    long long x, y;
    extgcd(num, mod, x, y);
    return (mod + x%mod)%mod;
  }
public:
  modint():num(0){}
  modint(const long long x):num((x < 0?(x+mod):x)%mod ){}
  friend modint operator+(const modint&a, const modint&b)
  {    return modint(a.num + b.num);  }
  friend modint operator-(const modint&a, const modint&b)
  {    return modint(a.num - b.num);  }
  friend modint operator*(const modint&a, const modint&b)
  {    return modint(a.num * b.num);  }
  friend modint operator/(const modint&a, const modint&b)
  {    return modint(a*b.modinverse());  }
  friend ostream& operator<<(ostream&os, const modint&a){
    os << a.num;
    return os;
  }
};
const ll mod = 7 + (1e+9);
using MI = modint<mod>;

int main(){
  ll n,m,k; cin >> n >> m >> k;
  MI sumx = 0, sumy = 0;
  rep(i,1,n)sumx = sumx + i * (n - i) * m * m;
  rep(i,1,m)sumy = sumy + i * (m - i) * n * n;
  MI acb;
  {
    MI a=1; MI x = n*m-2;
    rep(i,0,k-2){
      a = a * x;
      x = x - 1;
    }
    MI b=1;
    rep(i,1,k-1)b = b * i;
    acb = a/b;
  }
  debug(sumx);
  debug(sumy);
  debug(acb);
  cout << (sumx+sumy)*acb << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string S;
	cin>>S;
	bool A=S.length()%2==0;
	bool B=S[0]==S[S.length()-1];

	if (!A &&B || A&&!B){
		cout<<"Second"<<endl;
	}else{
		cout<<"First"<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	string s;cin>>s;int l=s.size();
	bool a=0,b=1;

	for(int i=0;i<(l-1)/2;i++){
		if(s[i]==s[l-i-1]) a=1;
		else {
			a=0;
			break;
		}
	}
		for(int i=0;i<l/4;i++){
			if(s[i]==s[l/2-i-1]&&s[i+l/2+1]==s[l-1-i]) b=1;
			else {
				b=0;
				break;
			}
		}
	if(a&&b) cout<<"Yes"<<"\n";
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val sc = if (args.size > 1) java.util.Scanner(java.io.File(args[1])) else java.util.Scanner(System.`in`)
  solve(sc)
}

fun solve(sc: java.util.Scanner) {
  val a = sc.nextLong()
  val b = sc.nextLong()
  val x = sc.nextLong()
  val start = a / x + if (a % x == 0L) 0 else 1
  val end = b / x
  println(end - start + 1)
}


Measured memory_bytes: 31264
a = input()
rev_a = ''.join(list(reversed(a)))
# join    iterator to list and  join them into one string
# we cannot change iterator into string directly

length = len(a)
#palindrome_check
if a == rev_a:
    a1 = a[0:length//2]
    rev_a1 = ''.join(list(reversed(a1)))
    
    a2 = a[length//2+1:length]
    rev_a2 = ''.join(list(reversed(a2)))
    
    if a1 == rev_a1 and a2 == rev_a2:
        print('Yes')
    else:
        print('No')
else:
    print('No')



Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
int n;
set<int>S;
main()
{
  cin>>n;
  for(int i=0;i<n;i++)
  {
    int c,x;cin>>c>>x;
    if(c==1)cout<<(S.find(x)!=S.end())<<endl;
    else if(c==0)S.insert(x),cout<<S.size()<<endl;
    else S.erase(x);
  }
}



Measured memory_bytes: 12376
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
  int N; cin >> N;
  long long a[N];
  for(int i=0; i<N; i++){
    cin >> a[i]; a[i] = a[i]-i-1;
  }
  
  sort(a, a+N);
  
  int mid; mid = a[N/2];
  long long sum = 0;
  for(int i=0; i<N; i++){
    sum = sum + abs(a[i]-mid);
  }
  
  cout << sum;
  
  return 0;
}

Measured memory_bytes: 1792