akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
	int x, y;
	while (true)
	{
		cin >> x >> y;
		if (x == 0 && y == 0)
			break;
		if (x > y)
		{
			int t = x;
			x = y;
			y = t;
		}
		cout << x << " " << y << endl;
	}
}


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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int A, B, C, K;
    cin>>A>>B>>C>>K;
    int rest = K, ans = 0;
    if(rest >= A){
        rest -= A;
        ans += A;
    }else{
        ans = rest;
        rest = 0;
    }
    if(rest >= B){
        rest -= B;
    }else{
        rest = 0;
    }
    
    if(rest >= 0){
        ans -= rest;
        rest = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3492
#include <iostream>
#include <string>
#include <numeric>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;

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

	vector<vector<int>> vec(M);

	for (int i = 0; i < M; ++i) {
		int k; cin >> k;
		vec[i].resize(k);
		for (int j = 0; j < k; ++j) {
			cin >> vec[i][j];
			--vec[i][j];
		}
	}

	vector<int> p(M);
	for (int i = 0; i < M; ++i) cin >> p[i];

	int ans = 0;
	for (int i = 0; i < (1 << N); ++i) {
		bool ok = true;
		for (int j = 0; j < M; ++j) {
			int c = 0;
			for (int id : vec[j]) {
				if ((i >> id) & 1) {
					++c;
				}
			}
			c %= 2;
			if (c != p[j]) {
				ok = false;
			}
		}
		if (ok) {
			++ans;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

int A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;

signed main(){
	int N;
	cin>>N;
	vector<int>a(N);
	rep(i,0,N)cin>>a[i];
	int ans = 0;
	rep(i,0,N-2){
		if(a[i+1]!=max({a[i],a[i+1],a[i+2]})&&a[i+1]!=min({a[i],a[i+1],a[i+2]}))ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

const ll mod = 1e9 + 7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> s, t;
  rep(i,n) {
    cin >> a[i];
    if (a[i] < 0) t.push_back(a[i]);
    else s.push_back(a[i]);
  }
 
  int S = s.size();
  int T = t.size();
  bool ok = false;
  if (S > 0) {
    if (n == k) ok = (T%2==0);
    else ok = true;
  } else {
    ok = (k%2==0);
  }
 
  ll ans = 1;
  if (!ok) {
    sort(a.begin(), a.end(), [](int x, int y) {
      return abs(x) < abs(y);
    });
    rep(i,k) ans *= a[i],ans %= mod;
  } else {
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (k%2 == 1) {
      ans *= s.back();
      s.pop_back();
    }
    vector<ll> p;
    while (s.size() >= 2) {
      ll x = s.back(); s.pop_back();
      x *= s.back(); s.pop_back();
      p.push_back(x);
    }
    while (t.size() >= 2) {
      ll x = t.back(); t.pop_back();
      x *= t.back(); t.pop_back();
      p.push_back(x);
    }
    sort(p.rbegin(), p.rend());
    rep(i,k/2) ans *= p[i]%mod,ans %= mod;
  }
 
  cout << (ans + mod) % mod << endl;
  return 0;
}


Measured memory_bytes: 6348
#include <stdio.h>

int main()
{
    /* ここから */
    int N;
    int otsuri;
    scanf("%d",&N);
    otsuri=(N/1000+1)*1000-N;
    if(otsuri>=1000) otsuri=0;
    printf("%d\n",otsuri);
    /* ここまで */
    return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    using Tup = tuple<string, ll, ll>;
    vector<Tup> rs(N);
    for (ll i = 0; i < N; i++) {
        string s;
        ll p;
        cin >> s >> p;
        rs[i] = make_tuple(s, -p, i);
    }
    sort(rs.begin(), rs.end());
    for (ll i = 0; i < N; i++) {
        cout << get<2>(rs[i]) + 1 << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 256
///RAIYAN_MAHIN
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m; cin >> n >> m; int cnt = 0;
    //if( n <= m) cout << n << '\n';
//    if(n > m )
//    {
//        if(n % m == 0)
//        {
//            int d = n / m; cout << d << '\n';
//        }
//        if(n % m != 0) 
//        {
//            int d = n / m; cout << d + 1 << '\n'; 
//        }
//    }
    //int cnt  = 0 ;
    while(n != 0 || n < 0)
    {
        n -= m;
        cnt++;
        if(n < 0 || n == 0) break;
    }
    cout << cnt << '\n';
    
}


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

#define N (1<<17)
using namespace std;

int n;
int a[N];
int used[N];
int uv;

int main()
{
	scanf("%d", &n);
	for (int i = 0;i < n;i++)
	{
		scanf("%d", &a[i]);
		if (a[i] == 0)
		{
			uv++;
			used[0]++, used[1]++;
		}
		else
		{
			used[a[i] - 1]++, used[a[i]]++, used[a[i] + 1]++;
		}
	}
	int mmx = 0;
	for (int i = 0;i < 100003;i++)
	{
		mmx = max(mmx, used[i]);
	}
	mmx = max(mmx, uv);
	printf("%d\n", mmx);
	return 0;
}


Measured memory_bytes: 1024
using Yorukatsu024.Questions;
using Yorukatsu024.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu024.Questions
{
    /// <summary>
    /// ABC142 A
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var odds = (n + 1) / 2;

            yield return (double)odds / n;
        }
    }
}


namespace Yorukatsu024
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu024.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu024.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11220
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  int a, b, c;
  int rec = 0,rho = 0;
  char c1, c2;

  while(cin >> a >> c1 >> b >> c2 >> c) {
    if(a*a + b*b == c*c)rec++;
    else if(a == b)rho++;  
  }
  cout << rec << endl;
  cout << rho << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  vector < string > ans(100, string(100, '.'));
  for (int i = 0; i < 50; ++i)
    ans[i] = string(100, '#');
  int cnt = a - 1;
  for (int i = 1; i < 49 && cnt; i += 2) {
    for (int j = 1; j < 99 && cnt; j += 2) {
      ans[i][j] = '.';
      --cnt;
    }
  }
  cnt = b - 1;
  for (int i = 51; i < 99 && cnt; i += 2) {
    for (int j = 1; j < 99 && cnt; j += 2) {
      ans[i][j] = '#';
      --cnt;
    }
  }
  cout << 100 << ' ' << 100 << '\n';
  for (int i = 0; i < 100; ++i) {
    for (int j = 0; j < 100; ++j)
      cout << ans[i][j];
    cout << '\n';
  }
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    for(int& x:a)
        scanf("%d",&x);
    vector<bool>dp(k+1);
    for(int i=0; i<=k; i++)
    {
        for(int x:a)
        {
            if(i>=x&&!dp[i-x])
            {
                dp[i]=true;
            }
        }
    }
    puts(dp[k]?"First":"Second");


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

constexpr int INF = 1e9+7;
constexpr ll INFL = 9*1e18;

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

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

int inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
template<typename T>inline void print(T&& x){cout<<setprecision(32)<<x<<endl;}


// TODO: write
int main() {
  int n;cin>>n;
  vector<pair<int,int>> a(n);
  rep(i,n)cin>>a[i].fi>>a[i].se;
  
  int cnt = 0;
  int ans = 0;
  rep(i,n){
    if(a[i].fi == a[i].se)cnt++;
    else cnt = 0;
    chmax(ans,cnt);
  }
  chmax(ans,cnt);
  print((ans >= 3)?"Yes": "No");
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
int n;
long long cnt[200001];
long long ans=0;
int a[200001];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        long long x = cnt[i];
        ans+=x*(x-1)/2;
    }
    for(int i=1;i<=n;i++)
    {
        int x = cnt[a[i]];
        cout<<ans-(x*(x-1)/2) + (x-1)*(x-2)/2<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef pair<ut,ut> prs;
const int SIZE=2*1e5;
const LL p=7+1e9;
LL N;
VI edges[SIZE];
inline void IN(ut &x){cin >> x;}
inline void INA(ut n,ut x[]){REP(i,n) cin >> x[i];}
inline void INE(ut m,VI edges[]){
	ut a,b;
	REP(i,m){
		cin >> a >> b;
		edges[a].PB(b);
		edges[b].PB(a);
	}
}
inline void INEC(ut m,Vpr edges[]){
	ut a,b,c;
	REP(i,m){
		cin >> a >> b >> c;
		edges[a].PB(pr(c,b));
		edges[b].PB(pr(c,a));
	}
}
LL solve(){
	LL A,B,C;
	cin >> A >> B >> C;
	LL times=0;
	REP(i,300000LL){
		if(A%2LL or B%2LL or C%2LL) return times;
		if(A==B && B==C) return -1;
		LL a=(A+B)/2LL,b=(B+C)/2LL,c=(A+C)/2LL;
		LL mini=min(A,min(B,C));

		A=a-mini;
		B=b-mini;
		C=c-mini;
		times++;
	}
	return -1;
}
int main(){
	cout << solve() << endl;

	return 0;
}

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

int get_perimeter(int x, int y) {
  return 2 * (x + y);
}

int get_area(int x, int y) {
  return x * y;
}

int main(int argc, char const *argv[])
{
  int a, b;
  cin >> a >> b;
  cout << get_area(a, b) << " " << get_perimeter(a, b) << "\n";
  return 0;
}


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

li = []
cnt = 0
c = a[0]
if n >= 2:
	for i in range(1,n):
		# print(c)
		if c >= a[i]:
			cnt += 1
			c = a[i]
		else:
			li.append(cnt)
			c = a[i]
			cnt = 0
		
		if i == n-1:
			li.append(cnt)
else:
	li.append(0)



print(max(li))

Measured memory_bytes: 14228
import java.io.*;
import java.util.*;
class Pair implements Comparable<Pair>
{
    int r;
    int c;
    int dist;
    public Pair(int r,int c,int d)
    {
        this.r=r;
        this.c=c;
        this.dist=d;
    }
    public int compareTo(Pair p)
    {
        if(this.dist>p.dist)
        return 1;
        else if(this.dist<p.dist)
        return -1;
        return 0;
    }
}
public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	static int h;
	static int w;
	static boolean possible(int r,int c)
	{
		if(r>=0 && r<h && c>=0 && c<w)
			return true;
		return false;
	}
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		int[]ar=split();
		h=ar[0];
	    w=ar[1];
		ar=split();
		int sr=ar[0]-1;
		int sc=ar[1]-1;
		ar=split();
		int er=ar[0]-1;
		int ec=ar[1]-1;
		char[][] mat=new char[h][w];
		for(int i=0;i<h;i++)
		{
			String s=br.readLine();
			for(int j=0;j<w;j++)
			{
				mat[i][j]=s.charAt(j);
			}
		}
		PriorityQueue<Pair>pq=new PriorityQueue<>();
		pq.add(new Pair(sr,sc,0));
		int[][] dis=new int[h][w];
		for(int i=0;i<h;i++)
		{
			Arrays.fill(dis[i],1000000000);
		}
		dis[sr][sc]=0;
		while(!pq.isEmpty())
		{
			Pair p=pq.poll();
			int d=p.dist;
			int r=p.r;
			int c=p.c;
			if(d>dis[r][c])
				continue;
			for(int i=r-2;i<=r+2;i++)
			{
				for(int j=c-2;j<=c+2;j++)
				{
					if(!possible(i,j) || ((i==r)&&(j==c)) || (mat[i][j]=='#'))
						continue;
					int d1=1;
					if((Math.abs(i-r)==1 && j==c) || (Math.abs(j-c)==1 && i==r))
						d1=0;
					if(dis[r][c]+d1<dis[i][j])
					{
						dis[i][j]=dis[r][c]+d1;
						pq.add(new Pair(i,j,dis[i][j]));
					}
				}
			}
		}
		if(dis[er][ec]!=1000000000)
		System.out.println(dis[er][ec]);
		else
			System.out.println(-1);
	}
}


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

A = [0]
B = [0]

for i in range(n):
    A.append(A[i] + a[i])

for i in range(m):
    B.append(B[i] + b[i])

ans = 0
j = m
for i in range(n+1):
    if A[i] > k:
        break
    else:
        while k - A[i] < B[j]:
            j -= 1

    ans = max(ans, i+j)

print(ans)

Measured memory_bytes: 134032
import java.util.Scanner;
public class Main {
	public static int N,K,a=-1;
	public static String ans="";
	//public static int a[][]=new int[5][5];

	public static void main(String[]args) {
		Scanner sc=new Scanner(System.in);
		N=sc.nextInt();
		for(int i=1;i<=N;i++) {
			int get=0;int tri=i;
			for(;;) {
				if(tri%2==0) {
					tri/=2;
					get++;
				}else {
					break;
				}
			}
			if(a<get) {
				a=get;
				ans=""+i;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23508
#include <iostream> 
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <bits/stdc++.h> 
using namespace std; 
int i,j,n,m,dp;

int min(int a,int b)
{
    if(a>b)
    return b;
    return a;
}

int mod (int a)
{
    if(a<0)
    return a*(-1);
    return a;
}

int steps(int *A,int n,int N)
{
    int dp[N];
    dp[0]=0;
    dp[1]=mod(A[1]-A[0]);
    dp[2]=min(dp[1]+mod(A[2]-A[1]),mod(A[2]-A[0]));
    for(i=3;i<N;i++)
    {
        dp[i]=min(dp[i-1]+mod(A[i]-A[i-1]),dp[i-2]+mod(A[i]-A[i-2]));
    }
   return dp[N-1];
}

int main()
{
    int N;
    cin>>N;
    int a;
    int A[N];
    for(int i=0;i<N;i++)
    {
        cin>>a;
        A[i]=a;
    }
    if(N==1)
    cout <<0;
    else if(N==0)
    cout <<0;
    else if(N==2)
    cout<<mod(A[1]-A[0]);
    else
    cout<<steps(A,0,N);
    return 0;
}

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

int main () {

  string s;
  cin >> s;
  int ans = 0;
  int count = 0;
  for (int j = 0; j < s.size();j++){
   if ((s.at(j) == 'A')||(s.at(j) == 'C')||(s.at(j) == 'G')||(s.at(j) == 'T')) count ++;
   else count = 0;
   if (count > ans) ans = count;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#!/env/usr/python3
n, k = input().split()
n = int(n)
k = int(k)

a = []
for i in range(n):
	a.append(int(input()))
	#print(a)

a.sort()
#print(a)


height_distance = []
for i, h in enumerate(a):
	if i <= n-k:
		#chosen = a[i:i+k]
		#height_distance.append(max(chosen)-min(chosen))
		height_distance.append(a[i+k-1]-a[i])
		#print(height_distance)

print(min(height_distance))


Measured memory_bytes: 11292
#include<stdio.h>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<stack>
#include<algorithm>
#include<string>
#include<string.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    set<int> ls;
    int n; cin >> n;
    while(n--){
        int a; cin >> a;
        ls.insert(a);
    }

    cout << ls.size() << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <string>
using namespace std;

struct Node
{
  int id;
  int parent;
  vector<int> children;
};

int getDepth(Node t[], Node n)
{
  int count = 0;
  Node node = n;
  while (node.parent != -1)
  {
    count++;
    node = t[node.parent];
  }
  return count;
}

int main()
{
  int n;
  scanf("%d", &n);

  Node tree[100000];
  for (int i = 0; i < 100000; i++)
    tree[i] = {-100, -1, {}};

  for (int i = 0; i < n; i++)
  {
    int id, k, tmp;
    scanf("%d%d", &id, &k);
    tree[id].id = id;
    for (int j = 0; j < k; j++)
    {
      scanf("%d", &tmp);
      tree[id].children.push_back(tmp);
      tree[tmp].parent = id;
    }
  }

  for (int i = 0; i < 100000; i++)
  {
    Node node = tree[i];
    if (node.id != -100)
    {
      string type = node.parent == -1 ? "root" : (node.children.size() == 0 ? "leaf" : "internal node");
      printf("node %d: parent = %d, depth = %d, %s, [",
             node.id, node.parent, getDepth(tree, node), type.c_str());
      int size = node.children.size();
      for (int j = 0; j < size; j++)
      {
        if (j != 0)
          printf(", ");
        printf("%d", node.children[j]);
      }
      printf("]\n");
    }
  }
  return 0;
}

Measured memory_bytes: 7148
N = int(input())
a = [int(i) for i in input().split()]
c = [0,0,0]
pos = True
for h in range(len(a)):
    try:
        n = a[h]
        a[h] = c.count(n)
        c[c.index(n)] += 1
    except:
        pos = False
        break
# print(a)
# print(c)
if pos:
    c = 1
    for n in a:
        c *= n%1000000007
    print(c%1000000007)
else:
    print(0)

Measured memory_bytes: 14396
#coding=UTF-8

def hinden(mozit):
    kaeshi=list(range(0,26,1))
    for idx in range(0,26,1):
        kaeshi[idx]=0


    for mozi in mozit:
        ire=ord(mozi)-ord('a')
        kaeshi[ire]+=1

    return kaeshi

N=int(input())

S=[]

for idx in range(0,N,1):
    S.append(input())
    
ans=hinden(S[0])
for idx in range(1,N,1):
    tmp=hinden(S[idx])
    for idy in range(0,26,1):
        ans[idy]=min(ans[idy],tmp[idy])

#表示
ansstr=''
for idx in range(0,26,1):
    ansstr+=(chr(ord('a') + idx))*ans[idx]

print(ansstr)


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int[] a = new int[3];
		for (int i=0; i<3; i++){
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int totalcost = 0;
		for (int i=1; i<3; i++){
			totalcost += a[i] - a[i-1];
		}
		System.out.println(totalcost);
	}
}

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

public class Main {

    public static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        long k = Long.parseLong(str[1]);

        str = br.readLine().split(" ");
        long base = Long.parseLong(str[0]);
        long max = base;
        for (int i = 1; i < n; i++) {
            long next = Long.parseLong(str[i]);
            base = gcd(base, next);
            max = Long.max(max, next);
            if (next == k) {
                System.out.println("POSSIBLE");
                System.exit(0);
            }
        }

        if (max < k) {
            System.out.println("IMPOSSIBLE");
        } else {
            if (base == 1) {
                System.out.println("POSSIBLE");
            } else {
                if (base == gcd(base, k)) {
                    System.out.println("POSSIBLE");
                } else {
                    System.out.println("IMPOSSIBLE");
                }
            }
        }
    }
}


Measured memory_bytes: 35796
import math
a,b,h,m = map(int,input().split())
if h == 0 and m >= 30: h = 12
if m == 0 and m >= 6: m = 60
kakudo = abs(h / 12 + m / 720 - m / 60)
co = math.cos(kakudo * math.pi * 2)
ans = a**2 + b**2 - 2 * a * b * co
print(math.sqrt(ans))

Measured memory_bytes: 9508
#!/usr/bin/env python3

import bisect


def solve(N, L):
    L = sorted(L)
    llen = len(L)
    # print(L)
    ans = 0
    for i in range(llen):
        for j in range(i+1, llen):
            k = bisect.bisect_left(L, L[i]+L[j], j+1)
            n = k - (j+1)
            # print(i, j, k, n)
            ans += n
    return ans


if __name__ == '__main__':
    N = int(input())
    L = list(map(int, input().split()))

    ans = solve(N, L)

    print(ans)


Measured memory_bytes: 3188
use std::collections::HashSet;
use std::cmp::max;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// fn main() {
//     input! {
//         S: chars,
//         T: chars,
//         n: i32,
//         m: i32,
//         U: chars
//     }
//     if S == U {
//         println!("{} {}", n-1, m);
//     } else {
//         println!("{} {}", n, m-1);
//     }
// }

/*
fn main() {
    input! {
        S: chars
    }
    let L = S.len();
    for i in 0..L {
        print!("x");
    }
    println!();
}*/

/*
fn main() {
    input! {
        N: usize,
        A: [i64; N],
    }
    let mut H = HashSet::new();
    for a in &A {
        H.insert(a);
    }
    if H.len() == A.len() {
        println!("YES");
    } else {
        println!("NO");
    }
}*/

fn main() {
    input! {
        N: usize,
        K: usize,
        P: [f64; N]
    }
    let mut tmp = 0.0;
    for i in 0..K {
        tmp += (P[i]+1.0)/2.0;
    }
    let mut ans = tmp;
    for i in K..N {
        tmp += (P[i]+1.0)/2.0 - (P[i-K]+1.0)/2.0;
        if ans < tmp {
            ans = tmp;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 6396
#include<stdio.h>
#include<string.h>

int main(void){
	
	int N;
	int a[1024];
	int min=1000;
	int max=0;

	int i;

	scanf("%d",&N);

	for(i = 0;i<N;i++){
		scanf("%d",&a[i]);
		if(min>a[i])min=a[i];
		if(max<a[i])max=a[i];
	}

	printf("%d\n",max-min);


	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000000)
#define MOD (1000000007)
#define MAX (500000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

class e{
public:
  ll a, b;
  e() {a = b = -1;}
  e(ll u, ll v) {a = u; b = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

vector<ll> fact(MAX, 0), fact_inv(MAX, 0);

ll pow_mod(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void prepare_comb_mod(ll n){
	fact[0] = 1LL;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

/////////////////////////////////////////////////////////

void Main() {
  ll N; cin >> N;
  ll n = N;
  rep(k, 1, pow(N, 0.5) + 1){
    if(N % k == 0){
      n = k;
    }
  }
  cout << n + N / n - 2 << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
#define PI acos(-1)
#define deb(x) cout<<#x<<" "<<x<<endl;
//ALWAYS USE ll DATA TYPE FOR INTEGER(FASTER THAN INTEGER AS WELL AS SOMETIMES WITHOUT USE LONG UR ANSWER WILL NOT ACCEPTED) && DOUBLE FOR DECIMAL VALUE
template<typename T> // for removing front element from the vector
void pop_front(std::vector<T> &v)
{
    if (v.size() > 0) {
        v.erase(v.begin());
    }
}
template<typename R> // for removing back element from the vector or can directly
void pop_back(std::vector<R> &v) // use vec.pop_back() function...
{
    if (v.size() > 0) {
        v.erase(v.begin()+v.size()-1);
    }
}

bool isprime(ll n)  //IN  O(sqrt(n))
{
    if(n<=1) return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;

    return true;
}

vector<ll> factors(ll n){    //IN  O(sqrt(n))

    vll v;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            v.pb(i);
            if((n/i)!=i)
            v.pb(n/i);
        }
    }
    return v;
}

ll power(ll a, ll n)  // using Binary Exponential in TC O(logn)
{                     // Self Written By </ME> :)
    ll res=1;
    while(1)
    {
        if(n%2){
            res=res*a; n--;
        }
        if(n==0) break;
        a=a*a; n/=2;
    }
    return res;
}

ll ts(ll arr[],int l,int r,int x) // ternary search to find x in sorted array arr
{
    
    while(l<=r)
    {
        ll mid1= l+(r-l)/3;
        ll mid2= r -(r-l)/3;
        if(arr[mid1]==x || arr[mid2]==x)
            return 1;
        if(x<arr[mid1])
            r=mid1-1;
        else if(x>arr[mid2])
            l=mid2+1;
        else
        {
            l=mid1+1;
            r=mid2-1;
        }
    }

    return -1;
}

int main() {
    auto start = chrono::high_resolution_clock::now();
    fio;
   
    ll T=1;
    //cin>>T;
    while(T--)
    {
        ll n; cin>>n;
        cout<<n/2+n%2<<"\n";
    }
    
    auto finish = chrono::high_resolution_clock::now();
    cerr << "Time elapsed: " << (chrono::duration<long double>(finish-start)).count() << "s\n";
    return 0;
}





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

int main() {
  int n;
  cin >> n;
  bool vanmo = false;
  while(n > 0){
    if(n % 10 == 7){
      vanmo = true;
    }
    n = n / 10;
  }
  if(vanmo){
    cout << "Yes";
  }else{
    cout << "No";
  }
	return 0;
}


Measured memory_bytes: 3632
n = int(input())
a = []
for i in range(n):
    x, y = map(int, input().split())
    a.append((x, y))
b = []
for i in range(n):
    x, y = map(int, input().split())
    b.append((x, y))
sus = [[] for i in range(n)]
for i in range(n):
    for j in range(n):
        if a[i][0] < b[j][0] and a[i][1] < b[j][1]:
            sus[i].append(j)

conn = [-1 for i in range(n)]

def dfs(x):
    global bio
    bio[x] = 1
    for y in sus[x]:
        if conn[y] == -1:
            conn[y] = x
            return 1
        if bio[conn[y]] == 0 and dfs(conn[y]):
            conn[y] = x
            return 1
    return 0

s = 0
for i in range(n):
    bio = [0 for j in range(n)]
    s += dfs(i)
print(s)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
 
using namespace std;

int main(){
    int X,Y;

    cin >> X >> Y;
    cout << X + Y / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
import collections
#import numpy as np
#print(np.diff(suuretsu))

n = int(input())
suuretsu = list(map(int,input().split()))

odd = [suuretsu[i] for i in range(n) if i % 2 != 0]
even = [suuretsu[i] for i in range(n) if i % 2 == 0]
ans = 0

#print(odd)
#print(even)

count_dict_odd = collections.Counter(odd)
count_dict_even = collections.Counter(even)

if count_dict_odd.most_common(n)[0][0] == count_dict_even.most_common(n)[0][0]:
  
  if count_dict_odd.most_common(n)[0][1] == count_dict_even.most_common(n)[0][1]:
    if len(count_dict_odd.most_common(n))== 1 and len(count_dict_even.most_common(n)) == 1:
      ans = int(n/2)
    elif len(count_dict_odd.most_common(n)) > len(count_dict_even.most_common(n)):
      ans = n-count_dict_odd.most_common(n)[0][1]-count_dict_even.most_common(n)[1][1]
    elif len(count_dict_odd.most_common(n)) < len(count_dict_even.most_common(n)):
      ans = n-count_dict_odd.most_common(n)[1][1]-count_dict_even.most_common(n)[0][1]
    else:
      if count_dict_odd.most_common(n)[1][1] >= count_dict_even.most_common(n)[1][1]:
        ans = n-count_dict_odd.most_common(n)[1][1]-count_dict_even.most_common(n)[0][1]
      else:
        ans = n-count_dict_odd.most_common(n)[0][1]-count_dict_even.most_common(n)[1][1]	      
  elif count_dict_odd.most_common(n)[0][1] > count_dict_even.most_common(n)[0][1]:
    ans = n-count_dict_odd.most_common(n)[0][1]-count_dict_even.most_common(n)[1][1]
  else:
    ans = n-count_dict_odd.most_common(2)[0][1]-count_dict_even.most_common(1)[0][1]
else:
    ans = n-count_dict_odd.most_common(n)[0][1]-count_dict_even.most_common(n)[0][1]

    
print(ans)
#print(len(count_dict_even.most_common(2)))
#print(len(count_dict_even.most_common(n)))
#print(count_dict_even.most_common(n))


Measured memory_bytes: 19040
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
  lint N;
  cin >> N;
  vector<lint> A(N);
  for(auto& elem : A) cin >> elem;
  A.push_back(-1);
  N++;

  vector<bool> inc(N);
  for(lint i=0; i+1<N; i++) {
    inc[i] = (A[i] <= A[i+1]);
  }

  lint money = 1000;
  lint share = 0;
  bool prev = false;
  for(lint i=0; i+1<N; i++) {
    // 買い時
    if(prev == false and inc[i] == true) {
      lint count = money / A[i];
      money -= count * A[i];
      share += count;
    }

    // 売り時
    if(prev == true and inc[i] == false) {
      money += share * A[i];
      share = 0;
    }

    prev = inc[i];
  }
  cout << money << endl;
}

Measured memory_bytes: 3628
import numpy as np


H, W = map(int, input().split())
lt = []

for i in range(H):
  lt += [list(input())]

  
def show(mat_):
  ptn = "%s" * mat_.shape[1]
  for row in mat_:
    print(ptn % tuple(row))
    
mat = np.array(lt)

mat = mat[:, ~np.all(mat==".", axis=0)]
mat = mat[~np.all(mat==".", axis=1), :]
show(mat)


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
	string s;cin>>s;
	int i,j;
	vector<int> sr(n+1,0);
	vector<int> sg(n+1,0);
	vector<int> sb(n+1,0);
	ll ans=0;
	rep(i,n)
	{
		sr[i+1]=sr[i];
		if(s[i]=='R')sr[i+1]++;
	}
	rep(i,n)
	{
		sg[i+1]=sg[i];
		if(s[i]=='G')sg[i+1]++;
	}
	rep(i,n)
	{
		sb[i+1]=sb[i];
		if(s[i]=='B')sb[i+1]++;
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(s[i]!='R'||s[j]!='G')continue;
			int dis=j-i;
			if(j+dis>=n)ans+=sb[n]-sb[j+1];
			else if(s[j+dis]!='B')ans+=sb[n]-sb[j+1];
			else ans+=sb[n]-sb[j+1]-1;
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(s[i]!='G'||s[j]!='R')continue;
			int dis=j-i;
			if(j+dis>=n)ans+=sb[n]-sb[j+1];
			else if(s[j+dis]!='B')ans+=sb[n]-sb[j+1];
			else ans+=sb[n]-sb[j+1]-1;
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(s[i]!='R'||s[j]!='B')continue;
			int dis=j-i;
			if(j+dis>=n)ans+=sg[n]-sg[j+1];
			else if(s[j+dis]!='G')ans+=sg[n]-sg[j+1];
			else ans+=sg[n]-sg[j+1]-1;
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(s[i]!='B'||s[j]!='R')continue;
			int dis=j-i;
			if(j+dis>=n)ans+=sg[n]-sg[j+1];
			else if(s[j+dis]!='G')ans+=sg[n]-sg[j+1];
			else ans+=sg[n]-sg[j+1]-1;
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(s[i]!='B'||s[j]!='G')continue;
			int dis=j-i;
			if(j+dis>=n)ans+=sr[n]-sr[j+1];
			else if(s[j+dis]!='R')ans+=sr[n]-sr[j+1];
			else ans+=sr[n]-sr[j+1]-1;
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			if(s[i]!='G'||s[j]!='B')continue;
			int dis=j-i;
			if(j+dis>=n)ans+=sr[n]-sr[j+1];
			else if(s[j+dis]!='R')ans+=sr[n]-sr[j+1];
			else ans+=sr[n]-sr[j+1]-1;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
/*
	Karya anak bangsa yang paling agung
	Author : Yohandi or... bukan..
*/

#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define endl "\n"

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define rep(a,x,y) for(int a=(int)x;a<=(int)y;++a)
#define repd(a,x,y,d) for(int a=(int)x;a<=(int)y;a+=d)
#define res(a,x,y) for(int a=(int)x;a>=(int)y;--a)
#define resd(a,x,y,d) for(int a=(int)x;a>=(int)y;a-=d)

// Ordered Set, Ordered Multiset
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define o_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
// .order_of_key(x) -> Number of elements less than x
// * .find_by_order(k) -> Kth smallest element (0-based)
// .erase(x) -> Remove all elements equal to x

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using lint=long long;

mt19937 rng(time(NULL));

lint Power(lint A,lint B,lint C){
	if(!B) return 1LL;
	lint tmp=Power(A,B>>1,C);
	return tmp*tmp%C*(B&1?A:1)%C;
}

int T;

int main(){
//	ios_base::sync_with_stdio(0);
//	cin.tie(0); cout.tie(0);
	T=1;
//	cin>>T;
	rep(t,1,T){
        int N;
        cin>>N;
        if(N%10==3) cout<<"bon\n";
        else if(N%10==0||N%10==1||N%10==6||N%10==8) cout<<"pon\n";
        else cout<<"hon\n";
	}
	return 0;
}




Measured memory_bytes: 3592
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int L,A,B;
    cin>>L>>A>>B;
    
    int cnt=0;
    L-=2*B;
    
    for(int i=0;;i++){
        if(i%2==0){
            if(L<A) break;
            L-=A;
            cnt++;
        }else{
            if(L<B) break;
            L-=B;
        }
    }
    cout1(cnt)
}

Measured memory_bytes: 256
A,B,C,D=map(int,input().split())
mod=998244353

dp=[[0]*D for _ in range(C)]

dp[A-1][B-1]=1

for i in range(A-1,C):
    for j in range(B-1,D):
        if i==A-1 and j==B-1:
            continue
        if i>A-1:
            dp[i][j]+=dp[i-1][j]*(j+1)
        if j>B-1:
            dp[i][j]+=dp[i][j-1]*(i+1)
        if i>A-1 and j>B-1:
            dp[i][j]-=dp[i-1][j-1]*(j)*(i)
        dp[i][j]%=mod

print(dp[C-1][D-1]%mod)


Measured memory_bytes: 133572
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)

def lcm_core(a,b):
    g = gcd_core(a,b)
    return (a*b)//g


a,b = map(int,input().split())
print(lcm_core(a,b))

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll n, m;
	cin >> n >> m;
	cout << abs(n - 2) * abs(m - 2) << endl;
	return 0;
}


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

int main()
{
	int n;
	int a[3];
	cin >> n;
	
	for (int i = 0; i < n; i++)
	{
		cin >> a[0] >> a[1] >> a[2];
		sort(a, a + 3);

		if ((a[0]*a[0]) + (a[1]*a[1]) == (a[2]*a[2])) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

N = INT()
cura, curb = MAP()
for i in range(N-1):
    a, b = MAP()
    # 比をそのままで、現在の票数より大きくする
    res = bisearch_min(0, INF, lambda m: a*m >= cura and b*m >= curb)
    cura, curb = a * res, b * res
ans = cura + curb
print(ans)


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

int main() {
    ll n,m;
    std::cin >> n>>m;
    vector<ll> a(m);
    vector<ll> b(m);
    vector<ll> c(m);
    vector<bool> able(n,false);
    for (int i = 0; i < m; i++) {
        std::cin >> a[i]>>b[i];
        for (int j = 0; j < b[i]; j++) {
            ll t;
            std::cin >> t;
            t--;
            c[i] += (ll)pow(2,t);
            able[t] = true;
        }
    }
    for (int i = 0; i < n; i++) {
        if(!able[i]){
            std::cout << -1 << std::endl;
            return 0;
        }
    }
    ll inf = 1e16;

    vector<vector<ll>> dp(5000,vector<ll>(m+1,inf));
    
    for (int i = 0; i < (1<<n); i++) {
        for (int j = 0; j < m; j++) {
            if(i==0){
                dp[i][j] = 0;
            }
            if(j!=0){
                dp[i][j] = dp[i][j-1];
            }
            dp[i][j] = min(dp[i][j], dp[ i & ~c[j] ][m-1] + a[j]);
        }
        for (int k = 0; k < (1<<n); k++) {
            dp[i & ~k][m-1] = min(dp[i][m-1],dp[i & ~k][m-1]);
        }
    }
    
    std::cout << dp[(1<<n)-1][m-1] << std::endl;
}


Measured memory_bytes: 39552
#include <iostream>

int main(){
   int N, Z, W;
   std::cin >> N >> Z >> W;

   int a[N];
   for(int i=0; i<N; ++i)
      std::cin >> a[i];

   if(N==1)
      std::cout << abs(a[0]-W) << std::endl;
   else
      std::cout << std::max(abs(a[N-1]-W),abs(a[N-2]-a[N-1])) << std::endl;

   return 0;
}


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

#define ALL(x) x.begin(), x.end()
using namespace std;

int point[100005];

int main(void){
    int n, m;
    cin >> n >> m;
    for(int i=0; i<m; i++){
        int x, y;
        cin >> x >> y;
        point[x]++;
        point[y]++;
    }
    for(int i=0; i<n; i++){
        if(point[i] % 2 == 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 640