akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 

 
const long double pi = 3.14159265358979323846;
const ll mod = 998244353;

namespace modop {
	ll madd(ll a, ll b) {
	  return (a + b) % mod;
	}
	ll msub(ll a, ll b) {
	  return (((a - b) % mod) + mod) % mod;
	}
	ll mmul(ll a, ll b) {
	  return ((a % mod) * (b % mod)) % mod;
	}
	ll mpow(ll base, ll exp) {
	  ll res = 1;
	  while (exp) {
		if (exp % 2 == 1){
			res = (res * base) % mod;
		}
		exp >>= 1;
		base = (base * base) % mod;
	  }
	  return res;
	}
	ll minv(ll base) {
	  return mpow(base, mod - 2);
	}
	ll mdiv(ll a, ll b) {
	  return mmul(a, minv(b));
	}
}

using namespace modop;


 
ll fact[300005], ifact[300005];

ll nck(ll n, ll k) {
  ll dem = (ifact[n - k] * ifact[k]) % mod;
  return (fact[n] * dem) % mod;
}

bool comp(pll& a, pll& b) {
  return a.f + a.s > b.f + b.s;
}

void solve() {
  ll n; cin >> n;
  string ss[n];
  vector<pll> pos, neg;
  f0r(i, n) {
    cin >> ss[i];
    ll v = 0, worst = 0;
    f0r(j, ss[i].length()) {
      if (ss[i][j] == '(') ++v;
      else --v;
      worst = min(worst, v);
    }
    worst = -worst;
    
    if (v >= 0) pos.pb(mp(worst, v));
    else neg.pb(mp(worst, v));
  }

  bool f = 1;
  ll cur = 0;

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

  f0r(i, pos.size()) {
    if (pos[i].s >= 0) {
      if (cur < pos[i].f) {
        f = 0;
        break;
      }
      cur += pos[i].s;
    }
  }

  sort(neg.begin(), neg.end(), comp);
  
  f0r(i, neg.size()) {
    if (cur < neg[i].f) {
      f = 0;
      break;
    }
    cur += neg[i].s;
  }

  if (cur != 0) f = 0;

  cout << (f ? "Yes\n" : "No\n");
}
 
int main() {
  fio();
  
  int T;
  T = 1;
  // cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 50300
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  string s;
  cin>>s;
  vector<Int> A(n,0),B(n,0);
  vector<set<Int> > G(n);
  for(Int i=0;i<m;i++){
    Int x,y;
    cin>>x>>y;
    x--;y--;
    if(G[x].count(y)) continue;
    G[x].emplace(y);
    G[y].emplace(x);
    if(s[x]=='A') A[y]++;
    if(s[x]=='B') B[y]++;
    if(s[y]=='A') A[x]++;
    if(s[y]=='B') B[x]++;
  }
  vector<Int> used(n,0);
  queue<Int> q;
  for(Int i=0;i<n;i++){
    if(A[i]&&B[i]) continue;
    used[i]=1;
    q.emplace(i);
  }
  while(!q.empty()){
    Int v=q.front();q.pop();
    for(Int u:G[v]){
      if(used[u]) continue;
      if(s[v]=='A') A[u]--;
      if(s[v]=='B') B[u]--;
      G[u].erase(v);
      if(A[u]&&B[u]) continue;
      used[u]=1;
      q.emplace(u);
    }
  }
  Int ans=0;
  for(Int i=0;i<n;i++) ans|=!used[i];
  cout<<(ans?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 32516
import java.io.IOException
import java.lang.NumberFormatException
import java.lang.StringBuilder
import kotlin.math.max
import kotlin.math.pow

object AMain{
    fun solve(){
        val d = nextInt()
        val t = nextInt()
        val s = nextInt()

        if(t * s >= d){
            println("Yes")
        }else{
            println("No")
        }
    }





    // Scanner based on uwi-san's Java code
    val stream = System.`in`
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0

    fun hasNextByte(): Boolean{
        if(ptr < buflen){
            return true
        }else{
            ptr = 0
            try{
                buflen = stream.read(buffer)
            }catch (e: IOException){
                e.printStackTrace()
            }
            if(buflen <= 0){
                return false
            }
        }
        return true
    }

    fun readByte() =
        if(hasNextByte()) buffer[ptr++]
        else -1

    fun isPrintableChar(c: Byte) = c in 33..126

    fun hasNext(): Boolean{
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
        return hasNextByte()
    }

    fun next(): String{
        if(!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while(isPrintableChar(b)){
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun nextLong(): Long{
        if(!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if(b == '-'.toByte()){
            minus = true
            b = readByte()
        }
        if(b !in '0'.toByte()..'9'.toByte())
            throw NumberFormatException()
        while(true){
            if(b in '0'.toByte()..'9'.toByte()){
                n *= 10
                n += b - '0'.toByte()
            }else if(!isPrintableChar(b)){
                return if(minus) -n else n
            }else{
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextInt(): Int{
        val n1 = nextLong()
        if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)
            throw NumberFormatException()
        return n1.toInt()
    }

    fun NextDouble() = next().toDouble()
}

fun main(){
    AMain.solve()
}



Measured memory_bytes: 33668
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=a; i<b; i++)
#define repi(i, a, b) for(int i=a; i>b; i--)
#define db(x) (cerr << #x << ": " << x << '\n')
#define iceil(n, x) ((n + x - 1) / x)
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define fi first
#define se second
#define umap unordered_map
#define umapi umap<int, int>
#define mapi map<int, int>
#define uset unordered_set
#define useti uset<int>
#define seti set<int>
#define pqueue priority_queue
#define si(a) scanf("%d", &a)
#define sll(a) scanf("%lld", &a)
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
#define MOD 1000000007
#define N 
using namespace std;

template<typename T>
using maxpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using minpq = priority_queue<T>;

inline int len(int i) {
	int l = 0;
	while(i) {
		i /= 10, l++;
	}
	return l;
}

inline vi tostr(int i) {
	vi s;
	while(i) {
		s.pb(i % 10);
		i /= 10;
	}
	reverse(all(s));
	return s;
}

bool has[10] = {0};

inline int findlrg(int d) {
	rep(i, d + 1, 10)
		if(has[i])
			return i;
	return d;
}

main()
{	
	#ifndef ONLINE_JUDGE
//		freopen("C:\\Users\\HP\\Desktop\\input.txt", "r", stdin);
//		freopen("C:\\Users\\HP\\Desktop\\output.txt", "w", stdout);
	#endif
	clock_t clk = clock();
	cerr << "I will return...\n";
	
	int n, k; cin >> n >> k;
	int l = len(n);
	vi s = tostr(n);
	
	rep(i, 0, k) {
		int j; cin >> j; has[j]++;
	}
	
	int mn = 10;
	
	rep(i, 0, 10) has[i] = !has[i];
	rep(i, 0, 10) {
		if(has[i]) {
			mn = i; break;
		}
	}
	
	vi v(l + 1, 0);
	
	int i = 1;
	while(i < l + 1) {
		v[i] = s[i - 1];
		if(has[v[i]]) {
			i++;
		}
		else {
			while(findlrg(v[i]) == v[i]) {
					i--;
				}
			
			int lrg = findlrg(v[i]);

			v[i++] = lrg;
			while(i < l + 1) {
				v[i++] = mn;
			}
		}
	}
	
	int ans = 0;
	rep(i, 0, l + 1) {
		ans *= 10;
		ans += v[i];
	}
	
	cout << ans << '\n';
	
	cerr << "...don't you ever hang your head.\n";
	cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << '\n';
}








Measured memory_bytes: 256
from itertools import cycle

while True:
    n = int(input())
    if not n:
        break
    qs = {}
    for i in range(n):
        d, t, *q = (int(s) for s in input().split())
        q = q[t:] + q[:t]
        if d not in qs:
            qs[d] = q
        else:
            qs[d] = [a + b for a, b in zip(qs[d], q)]
    L = 16 * 9 * 5 * 7 * 11
    ps = [13, 17, 19, 23, 1]
    psum = sum(max(qs.pop(i, [0])) for i in ps)
    qmax = max(sum(j) for i, j in zip(range(L-1),
                                      zip(*[cycle(q) for q in qs.values()])
                                      )
               )
    print(psum + qmax)

Measured memory_bytes: 6740
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] lo =reader.readLine().split(" ");
		int L = Integer.parseInt(lo[0]);
		int R = Integer.parseInt(lo[1]);
		int d = Integer.parseInt(lo[2]);
		int a = (L-1)/d;
		int b = (R)/d;
		System.out.println((b-a));
	}
}


Measured memory_bytes: 32596
kazu, ashi = map(int, input().split())
tsuru, kame = 0, 0
hantei = 0

for i in range(kazu+1):
    kame = i
    tsuru = kazu - i
    if kame * 4+ tsuru * 2 == ashi:
        hantei = 1
        break

if hantei:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9096
fun main(args : Array<String>) {
    val (N, A, B, C) = readLine()!!.split(" ").map { it.toInt() }
    var l = mutableListOf<Int>()
    (1..N).forEach {
        l.add(readLine()!!.toInt())
    }

    fun dfs(times: Int, sum_for_a: Int, sum_for_b: Int, sum_for_c: Int) : Int {
        if (times == N) {
            if (listOf(sum_for_a, sum_for_b, sum_for_c).min() == 0) {
                return Int.MAX_VALUE - 10
            }
            return Math.abs((sum_for_a - A)) + Math.abs(sum_for_b - B) + Math.abs(sum_for_c - C)
        }
        val li = l[times]

        val candidate1 = dfs(times + 1, sum_for_a, sum_for_b, sum_for_c)
        val candidate2 = dfs(times + 1, sum_for_a + li, sum_for_b, sum_for_c) + 10
        val candidate3 = dfs(times + 1, sum_for_a , sum_for_b + li, sum_for_c) + 10
        val candidate4 = dfs(times + 1, sum_for_a , sum_for_b, sum_for_c + li) + 10

        return listOf(candidate1, candidate2, candidate3, candidate4).min()!!
    }

    println(dfs(0, 0, 0, 0) - 30)
}

Measured memory_bytes: 46204
from collections import defaultdict

N = int(input())

dic = defaultdict(int)


def factoring(k): #kを因数分解し、素因数とその個数を辞書に入れて返す。
    import math
    n = int(math.sqrt(k))+2
    for i in range(2, n):
        count = 0
        while k%i == 0:
            count += 1
            k = k//i
        if count != 0:
            dic[i] += count
    if k != 1: #sqrt(k)までチェックしてもkが1になっていない --> kが素因数
        dic[k] += 1
    return

for i in range(1, N + 1):
    factoring(i)

ans = 0
for i in dic:
    if dic[i] >= 74:
        ans += 1
    if dic[i] >= 2:
        count = 0
        for j in dic:
            if i == j:
                continue
            if dic[j] >= 4:
                count += 1
        ans += count * (count - 1) // 2
    if dic[i] >= 2:
        for j in dic:
            if i == j:
                continue
            if dic[j] >= 24:
                ans += 1
    if dic[i] >= 4:
        for j in dic:
            if i == j:
                continue
            if dic[j] >= 14:
                ans += 1

print (ans)
# print (dic)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

vec b(8);
ll cost(ll a, ll s){
    ll temp = 0, m = -10;
    rep(i,N){
        if((s>>i)&1) {
            temp += b.at(i);
            m += 10;
        }
    }
    return abs(a - temp) + m;
}

int main(){
    ll Q;
    cin>>A>>B>>Q;
    vec s(A+2), t(B+2), x(Q);
    rep(i,A) cin>>s[i+1];
    rep(i,B) cin>>t[i+1];
    rep(i,Q) cin>>x[i];
    s[0] = t[0] = -2e+11;
    s[A+1] = t[B+1] = 2e+11;
    rep(i,Q){
        ll si = lower_bound(s.begin(),s.end(),x[i]) - s.begin();
        ll ti = lower_bound(t.begin(),t.end(),x[i]) - t.begin();
        ll temp = 1e+11;
        reps(j,si-1,si+1){
            reps(k,ti-1,ti+1){
                temp = min({temp,
                            abs(s[j]-t[k])+abs(x[i]-s[j]),
                            abs(s[j]-t[k])+abs(x[i]-t[k])});
            }
        }
        cout<<temp<<endl;
    }
}

Measured memory_bytes: 3712
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
queue<int> q;
int n;
vector<int> edge[100010];
int a[100010];
int main()
{
	cin >>n;
	for (int i=0;i<n-1;i++)
	{
		int x,y;
		cin >>x>>y;
		x--,y--;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	fill(a,a+n,-1);
	a[0]=1;
	a[n-1]=0;
	q.push(0);
	q.push(n-1);
	while (!q.empty())
	{
		int x=q.front(); q.pop();
		int col=a[x];
		for (int i=0;i<edge[x].size();i++)
		{
			if (a[edge[x][i]]==-1)
			{
				a[edge[x][i]]=col;
				q.push(edge[x][i]);
			}
		}
	}
	int f=0,s=0;
	for (int i=0;i<n;i++)
	{
		if (a[i]) f++;
		else s++;
	}
	cout <<(f>s ? "Fennec" : "Snuke");
	return 0;
}

Measured memory_bytes: 6272
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Point{
	int x,y;
	Point(){}
	Point(int x,int y):x(x),y(y){}
};
int dist2(Point a,Point b)
{
	return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
ostream& operator<<(ostream& os,const Point& p){return os<<mp(p.x,p.y);}

int main()
{
	for(int n;~scanf("%d",&n);){
		vector<Point> ps;
		rep(i,n){
			int x,y; scanf("%d%d",&x,&y);
			ps.emplace_back(x+10000,y+10000);
		}
		
		int res=INFTY;
		stable_sort(all(ps),[](Point a,Point b){return a.x<b.x;});
		rep(i,n-1) res=min(res,dist2(ps[i],ps[i+1]));
		stable_sort(all(ps),[](Point a,Point b){return a.y<b.y;});
		rep(i,n-1) res=min(res,dist2(ps[i],ps[i+1]));
		
		vvi q(20001);
		rep(i,n) q[ps[i].y].push_back(ps[i].x);
		
		for(Point p:ps){
			int t=max(p.y-int(ceil(sqrt(res))+EPS),0);
			int b=min(p.y+int(ceil(sqrt(res))+EPS),20000);
			repi(i,t,b+1){
				int dy=i-p.y;
				int mn=p.x-ceil(sqrt(max(res-dy*dy,0))+EPS);
				int mx=p.x+ceil(sqrt(max(res-dy*dy,0))+EPS);
				int l=lower_bound(all(q[i]),mn)-q[i].begin();
				int r=upper_bound(all(q[i]),mx)-q[i].begin();
				repi(j,l,r){
					if(i==p.y && q[i][j]==p.x) continue;
					res=min(res,dy*dy+(p.x-q[i][j])*(p.x-q[i][j]));
				}
			}
		}
		printf("%d\n",res);
	}
	
	return 0;
}

Measured memory_bytes: 8884
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
static int n = int.Parse(Console.ReadLine());
static long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
static long[] bits = new long[n+1];

	static void Main()
	{
    long[][] vertexes = new long[n][];//宣言
    for(int i = 0; i < n; i++) vertexes[i] = new long[]{i,nums[i]};//代入
    Array.Sort(vertexes, (a, b) => a[1].CompareTo(b[1]));
    for(int i = 0; i < n; i++) vertexes[i][1] = i+1;
    Array.Sort(vertexes, (a, b) => a[0].CompareTo(b[0]));
    for(int i = 0; i < n; i++) nums[i] = vertexes[i][1];
  
    long answer = 0;
    for(long i = 0; i < n; i++)
    {
      answer += i - BitSum(nums[i]);
      BitAdd(nums[i], 1);
    }
    
		Console.WriteLine(answer);
	}

  static void BitAdd(long i, long x)//BITでiだけにx加算
  {
    while(i <= n)
    {
      bits[i] += x;
      i += i&-i;
    }
  }

  static long BitSum(long i)//BITでi以下の総和を計算
  {
    long sum = 0;
    while(i > 0)
    {
      sum += bits[i];
      i -= i&-i;
    }
    return sum;
  }
  
}


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

using namespace std;

struct bool_vector_t: vector< bool >
{
    bool invalid( int M ) const
    {
        /// returns true if two consecutive horizontal line segments exist

        for ( int i = 0, j = 1; j < M; i = j++ )
            if ( at( i ) and at( j ) )
                return true;

        return false;
    }
};

struct bits_t: vector< bool_vector_t >
{
    bits_t( int N, int W )
    {
        resize( N );

        /// generate all possible subsets of horizontal M line segments

        for( int k = 0; k < N; k++ )
        {
            at( k ).resize( W, false );

            for( int j = 0, l = k; j < W; j++, l >>= 1 )
                if ( l & 1 )
                    at( k ).at( j ) = true;
        }
    }
};

struct dp_t:  vector< vector< int > >
{
    dp_t( int H, int W )
    {
        resize( H + 1 );

        for( auto& row: *this )
            row.resize( W, 0 );

        at( 0 ).at( 0 ) = 1;
    }

    void add( int i, int j, int k, int M, const bits_t& bit )
    {
        int t = j - 1, u = i + 1, v = 0; /// No change to the vertical line

        if( t >= 0 and bit[ k ][ t ] )
            v = -1; /// move to the vertical line to the left
        else
            if( j < M and bit[ k ][ j ] )
                v = 1; /// move to the vertical line to the right

        at( u ).at( v += j ) += at( i ).at( j ), at( u ).at( v ) %= 1000000007;
    }
};

struct valid_t: vector< bool >
{
    valid_t( int N, int M, bits_t& bit )
    {
        resize( N, false );

        for( int k = 0; k < N; k++ )
            if ( not bit[ k ].invalid( M ) )
                at( k ) = true;
    }
};

int main()
{
    ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );

    int H, W, K, M, N; cin >> H >> W >> K, M = W - 1, N = 1 << M;

    bits_t bit( N, W ); dp_t dp( H, W ); valid_t valid( N, M, bit );

	for( int i = 0; i < H; i++ )
		for( int j = 0; j < W; j++ )
			for( int k = 0; k < N; k++ )
                if ( valid[ k ] )
                    dp.add( i, j, k, M, bit );

	cout << dp[ H ][ K - 1 ];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n, s;
vector<int> a;
LL dp[ 100 ][ 21 ];
LL solve( int now, int f ) {
    if ( dp[ now ][ f ] >= 0 ) {
        return dp[ now ][ f ];
    }
    LL res = 0;
    if ( now == n - 1 ) {
        res = s == f;
    }
    else {
        if ( f + a[ now ] <= 20 ) {
            res += solve( now + 1, f + a[ now ] );
        }
        if ( f - a[ now ] >= 0 ) {
            res += solve( now + 1, f - a[ now ] );
        }
    }
    return dp[ now ][ f ] = res;
}
int main() {
    scanf( "%d", &n );
    a.resize( n - 1 );
    for ( int i = 0; i < n - 1; i++ ) {
        scanf( "%d", &a[ i ] );
    }
    scanf( "%d", &s );
    memset( dp, -1, sizeof( dp ) );
    printf( "%lld\n", solve( 1, a[ 0 ] ) );
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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;}

int main(){
    int l,r,d;cin>>l>>r>>d;
    int cnt=0;
    for(int i=l;i<=r;++i){
        if(i%d==0)cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  int g = 0;
  int mx = 0;
  for (int i = 0; i < N; i++){
    g = __gcd(g, A[i]);
    mx = max(mx, A[i]);
  }
  if (K > mx || K % g != 0){
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << "POSSIBLE" << endl;
  }
}

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
  
  
  // 10の15条

  int n;
  cin>>n;

  vec c;

  while(n>=0){
    c.pb(n%26);
    if(n%26==0){
      n/=26;
      n--;
    }
    else{
      n/=26;
    }
    if(n==0) break;
  }
  

  reverse(all(c));

  rep(i,(ll)c.size()){
    if(c[i]==0) c[i]=26;
    c[i]--;
    char x='a';
    char y=x+c[i];
    cout<<y;
  }
  cout<<endl;
  
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7812
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) (a).begin(), (a).end()
#define pw(x) (1ll<<(x))
#define lb(x) ((x) & -(x))
#define endl "\n"
#define FI(x) freopen(#x".in","r",stdin)
#define FO(x) freopen(#x".out","w",stdout)
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
//typedef uniform_int_distribution<ll> RR;
const int P = 1e9 + 7;
//ll rnd(ll l, ll r) { mt19937 gen(rand()); RR dis(l, r); return dis(gen); }
int add(int a, int b) {if((a += b) >= P) a -= P; return a < 0 ? a + P : a;}
int mul(int a, int b) {return 1ll * a * b % P;}
int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
const int N = 1e5 + 7;
int n, m, a[N], p;
int main() {
	//FI(a);
	ios::sync_with_stdio(0);
	cin.tie(0);
	//cout << setiosflags(ios::fixed);
	//cout << setprecision(2);
	cin >> n >> m;
	rep(i, 1, n+1) cin >> a[i];
	rep(i, 1, n) if (a[i] + a[i+1] >= m) {
		p = i; break;
	}
	if (!p) cout << "Impossible" << endl;
	else {
		cout << "Possible" << endl;
		rep(i, 1, p) cout << i << endl;
		per(i, p+1, n) cout << i << endl;
		cout << p << endl;
	} 
	return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL UPPER = 1e9;

int main(){
    
    // 1. 入力情報取得.
    LL S;
    scanf("%lld", &S);
    
    // 2. 三頂点を計算.
    // (X1, Y1) は, 原点と設定.
    // 座標平面上で三角形の面積を計算する公式.
    // https://mathwords.net/x1y2hikux2y
    LL X1, X2, X3, Y1, Y2, Y3;
    X1 = 0LL;
    Y1 = 0LL;
    X2 = min((LL)sqrt(S) + 1LL, UPPER);
    Y3 = min((LL)sqrt(S) + 1LL, UPPER);
    Y2 = 1LL;
    X3 = X2 * Y3 - S;
    // printf("%lld\n", X2 * Y3 - Y2 * X3);
    
    // 3. 出力 ～ 後処理.
    printf("%lld %lld %lld %lld %lld %lld\n", X1, Y1, X2, Y2, X3, Y3);
    return 0;

}

Measured memory_bytes: 256
import sys
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()

co = []
for i in range(n):
    co.append(na())

co.sort(key=itemgetter(1))
for i in range(n):
    co[i][1] = i

# print(co)
ft = [0] * (n + 5)

co.sort(key=itemgetter(0), reverse=True)

ups = [0] * n
downs = [0] * n

def addfenwick(ft, i, v):
    if v == 0 or i < 0: return
    i += 1
    while i < len(ft):
        ft[i] += v
        i += i&-i

def sumfenwick(ft, i):
    s = 0
    i += 1
    while i > 0:
        s += ft[i]
        i -= i&-i
    return s

for i in range(n):
    c = co[i]
    downs[n-1-i] = sumfenwick(ft, c[1])
    ups[n-1-i] = i - downs[n-1-i]
    addfenwick(ft, c[1], 1)

ft = [0] * (n+5)
co = co[::-1]

mod = 998244353
ps = [0] * (n+5)
ps[0] = 1
for i in range(1, n+4):
    ps[i] = ps[i-1] * 2 % mod

ans = 0
for i in range(n):
    c = co[i]
    d = sumfenwick(ft, c[1])
    u = i - d

    # print(d, u, ups[i], downs[i])
    ans += (ps[d]-1) * (ps[ups[i]]-1) * ps[u+downs[i]]
    ans += (ps[u]-1) * (ps[downs[i]]-1) * ps[d+ups[i]]
    ans -= (ps[d]-1) * (ps[ups[i]]-1) * (ps[downs[i]]-1) * (ps[u]-1)
    ans += ps[n-1]
    addfenwick(ft, c[1], 1)

ans %= mod
if ans < 0:
    ans += mod
print(ans)



Measured memory_bytes: 102620
s = input()
t = input()
flag = True
d1,d2 = dict(),dict()
for i in range(len(s)):
    if s[i] in d1:
        if d1[s[i]] != t[i]:
            flag = False
    else:
        d1[s[i]] = t[i]
        
for i in range(len(s)):
    if t[i] in d2:
        if d2[t[i]] != s[i]:
            flag = False
    else:
        d2[t[i]] = s[i]

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000

#define rep(i, a, n) for(int i = a; i < n; i++)
#define rep2(i, a, n) for(int i = a; i <= n; i++)
#define rrep(i, a, n) for(int i = a; i > n; i--)
#define rrep2(i, a, n) for(int i = a; i >= n; i--)
#define lrep(i, a, n) for(long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

int main()
{
    int a;
    string s;

    cin >> a >> s;

    if(a < 3200) { cout  << "red" << endl; } 
    else { cout << s << endl; }

    return 0;
}


Measured memory_bytes: 256
n, c, k = map(int,input().split())

t = []
for i in range(n):
    t.append(int(input()))
t.sort()

tp = 0
count = 0
wait = 0
pa = 0
for i in range(n):
    ti = t[i]
    if pa == 0:
        wait = 0
    else:
        wait += ti-tp
    pa += 1
    if pa == c+1 or wait > k: 
        count += 1
        pa = 1
        wait = 0
    tp = ti
print(count+1)

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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int X;
	int K;
	cin >> X >> K;
	vector<int> r(K + 1);
	r[0] = 0;
	for (int i = 1; i <= K; i++) cin >> r[i];
	int Q;
	cin >> Q;
	int L = 0, R = X, c = 0;
	for (int i = 0, j = 1; i < Q; i++) {
		int t, a;
		cin >> t >> a;
		while (j <= K && t >= r[j]) {
			if (j % 2 == 1) {
				c -= r[j] - r[j - 1];
			} else {
				c += r[j] - r[j - 1];
			}
			R = max(min(R, X - c), -c);
			L = min(max(L, -c), X - c);
			j++;
		}
		int ans;
		if (a < L) {
			ans = L + c;
		} else if (a > R) {
			ans = R + c;
		} else {
			ans = a + c;
		}
		if (j % 2 == 1) ans = max(ans - t + r[j - 1], 0);
		else ans = min(ans + t - r[j - 1], X);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>

int main(void){
        int height,width,i=0,j=0;
        while(1){
                scanf("%d %d",&height,&width);
                if(height==0 && width==0)break;
                while(i<height){
                        while(j<width){
                                if(j%2==0) {
                                        if(i%2==0){
                                                printf("#");
                                        } else {
                                                printf(".");
                                        }
                                } else  {
                                        if(i%2==0){
                                                printf(".");
                                        } else {
                                                printf("#");
                                        }
                                }
                                j++;
                        }
                        j=0;
                        i++;
                        puts("");
                }
                i=0;
                j=0;
                puts("");
        }

        return 0;
}


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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
// clang-format on

using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;

const long long MOD = 1000000007;

void dfs(VVI &tree, VVLL &dp, int u, int prev)
{
  for (auto v : tree[u])
  {
    if (v != prev)
    {
      dfs(tree, dp, v, u);
      dp[u][0] = dp[u][0] * ((dp[v][0] + dp[v][1]) % MOD) % MOD;
      dp[u][1] = (dp[u][1] * dp[v][0]) % MOD;
    }
  }
}

int main()
{
  IOS;
  int N;
  cin >> N;

  VVI tree(N + 1, VI());
  int x, y;
  forn(i, 0, N - 1)
  {
    cin >> x >> y;
    tree[x].push_back(y);
    tree[y].push_back(x);
  }

  VVLL dp(N + 1, VLL(2, 1));
  dfs(tree, dp, 1, -1);
  cout << (dp[1][0] + dp[1][1]) % MOD << endl;

  return 0;
}


Measured memory_bytes: 22284
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

void strReplace(std::string& str, const std::string& from,
                const std::string& to) {
  std::string::size_type pos = 0;
  while (pos = str.find(from, pos), pos != std::string::npos) {
    str.replace(pos, from.length(), to);
    pos += to.length();
  }
}

vector<string> createSet(string s) {
  vector<string> az_set;
  string az = "";
  for (char c : s) {
    if (c == 'B' || c == 'C') {
      if (az.size() != 0) {
        az_set.push_back(az);
      }
      az = "";
    } else if (c == 'A' || c == 'Z') {
      az = az + c;
    }
  }
  if (az.size() != 0) {
    az_set.push_back(az);
  }

  return az_set;
}

int main() {
  string s;
  cin >> s;

  // BCをZに置換
  strReplace(s, "BC", "Z");

  // AとZのみでできた塊を見つける
  vector<string> az_set = createSet(s);

  // 全部の塊のZを左に寄せるのに何回操作するか計算する
  ll result = 0;
  for (string az : az_set) {
    ll sub_result = 0;
    ll a_count = 0;
    for (char c : az) {
      if (c == 'A') {
        a_count++;
      } else if (c == 'Z') {
        sub_result += a_count;
      }
    }
    // cout << *it << "の移動は" << sub_result << "回" << endl;
    result += sub_result;
  }

  cout << result << endl;

  return 0;
}


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

int main(){
  int a,b,c,k;cin >> a >> b >> c >> k;
  for(int l = 0;l < k;++l){
    if(c <= a || c <= b) c *= 2;
    else if(b <= a)b *= 2;
    
    if(a < b && b < c){cout << "Yes";return 0;}
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
	int K;
	cin >> K;
	cout << a[K - 1] << endl;
	return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
maxA = max(A)

counts = [0 for _ in range(maxA+1)]
for a in A:
  counts[a] += 1

integers = [1 for _ in range(maxA+1)]
integers[0] = 0
integers[1] = 0
max_count = 0
for i in range(maxA+1):
   if integers[i] >= 1:
    count = 0
    for j in range(i,maxA+1,i):
      count += counts[j]
      integers[j] = 0
    max_count = max(max_count,count)

if max_count == N:
  answer = 'not coprime'
elif max_count >= 2:
  answer = 'setwise coprime'
else:
  answer = 'pairwise coprime'

print(answer)

Measured memory_bytes: 217372
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
 string a[9] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
 int n;
 cin >> n;
 for(int k=0; k<n; k++){
   string s;
   cin >> s;
   for(int i=0; i<(int)s.size(); i++){
     char c = s[i];
     int count = 0;
     for(i=i+1; i<(int)s.size(); i++){
       if(s[i] != c) break;
       count++;
    }
    i--;
    if(c=='0') continue;
    int num = c-'0'-1;
    int tmp = count % a[num].size();
    cout << a[num][tmp];
    }
    cout << endl;
 }
 return 0;
}




Measured memory_bytes: 3140
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	string s;
	cin>>s;
	int mx=0;
	string t="";
	for(int i=0;i<s.size()-1;i++){
		t+=s[i];
		if(t.size()%2)continue;
		string t1="";
		string t2="";
		for(int j=0;j<t.size();j++){
			if(j<t.size()/2)t1+=t[j];
			else t2+=t[j];
		}
		if(t1==t2)mx=max(mx,i+1);
	}
	cout<<mx<<endl;
	return 0;
}


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

#define y1 as214
#define ii pair < int , ll >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back

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

#define ll long long
#define oo INT_MAX

/// dp[i][j] là  số điểm nhiều nhất nhận được trong i ngày đầu và ngày thứ i chọn hoạt động thứ j.

const int N = 1e5 + 5;
ll n , k;
ll a[N][5];
ll dp[N][5];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    FOR(i , 1 , n)
        FOR(j , 1 , 3)
            cin >> a[i][j];
    dp[1][1] = a[1][1];
    dp[1][2] = a[1][2];
    dp[1][3] = a[1][3];
    FOR(i , 2 , n)
    {
        FOR(j , 1 , 3)
            FOR(k , 1 , 3)
                if(j != k)
                    dp[i][k] = max(dp[i - 1][j] + a[i][k] ,  dp[i][k]);
    }
    cout << max(dp[n][1] , max(dp[n][2] , dp[n][3]));
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
 
const int INF=1e15;

signed main(){
    int H,N;
    cin>>H>>N;
    int A[N],B[N];
    int AM=0;
    REP(i,N){
        cin>>A[i]>>B[i];
        AM=max(AM,A[i]);
    }
    vector<int>dp(H+AM,INF);
  	dp[0]=0;
    vector<bool>check(H+AM,false);
    check[0]=true;
    int ans=INF;
    for(int i=1;i<=H+AM-1;i++){
        REP(j,N){
            if(i-A[j]>=0){
                if(check[i-A[j]]){
                    dp[i]=min(dp[i],dp[i-A[j]]+B[j]);
                  	check[i]=true;
                }
            }
            if(i>=H&&check[i])ans=min(ans,dp[i]);
        }
    }
    cout<<ans<<endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; i++) cin >> v[i];
    sort(v.begin(), v.end());
    cout << v[n-1] - v[0] << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe



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


int a,b,ans;
cin >> a >> b;
ans = (a+b)/2;

if ((a+b)%2 == 0)
{
    cout << ans << endl;
}else
{
    cout << "IMPOSSIBLE" << endl;
}







//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <chrono>
#include <random>
#include <cstdio>
#define ll long long int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mod 998244353LL
#define rep(i,n) for(ll i=0;i<n;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define pll pair<ll, ll>
#define pint pair<int, int>
#define S second
#define F first
#define all(c) (c).begin(),(c).end()
using namespace std;
ll power(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 modInverse(ll a){return power(a,mod-2);}
const int N=500001;
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
#define pi 3.14159265358979323846264338
using namespace std; 
ll max(ll a, ll b){ if(a>b)return a;return b;}
ll min(ll a, ll b){ if(a < b) return a;return b;}
ll inf = 100000000000000000;

void solve() 
{
    int n;
    cin>>n;

    vi a(n);
    rep(i, n) cin>>a[i];

    int mn = INT_MAX, mx = INT_MIN;
    int mxidx, mnidx;

    rep(i, n)
    {
        if(a[i] < mn) mnidx = i;
        mn = min(mn, a[i]);
        if(a[i] > mx) mxidx = i;
        mx = max(mx, a[i]);
    }

    if(mx >= 0 && mn >= 0)
    {
        cout<<n-1<<endl;
        rep(i, n-1)
        {
            cout<<i+1<<" "<<i+2<<endl;
        }
        return;
    }

    if(mx <= 0 && mn <= 0)
    {
        cout<<n-1<<endl;
        rep(i, n-1)
        {
            cout<<n-i<<" "<<n-i-1<<endl;
        }
        return;
    }

    if(abs(mx) >= abs(mn))
    {
        cout<<2*n-1<<endl;
        rep(i, n)
        {
            cout<<mxidx + 1<<" "<<i + 1<<endl;
        }
        rep(i, n-1)
        {
            cout<<i+1<<" "<<i+2<<endl;
        }   
        return;

    }

    cout<<2*n-1<<endl;
    rep(i, n)
    {
        cout<<mnidx+1<<" "<<i+1<<endl;
    }
    rep(i, n-1)
    {
        cout<<n-i<<" "<<n-i-1<<endl;
    }

}

int main()
{   

    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3800
/// Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define for0(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     int l;
     while(cin>>l){
        double ans=(double)l/3.0;
        cout<<fixed<<setprecision(12)<<pow(ans,3.0)<<endl;
     }

     return 0;

}
///Alhamdulillah


Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int [] a = {1, 3, 5, 7, 8, 10,12};
		int [] b = {4, 6, 9, 11};
		int c = 2;
		int x = sc.nextInt();
		int y = sc.nextInt();
		int cx = 3;
		int cy = 3;
		for(int val : a) {
			if(val == x) {
				cx = 1;
			}
			if (val == y) {
				cy = 1;
			}
		}
		for(int valu : b) {
			if(valu == x) {
				cx = 2;
			}
			if(valu == y) {
				cy = 2;
			}
		}
		if(cx == cy) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


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

#define MAX_N 2000
#define MAX_M 3000

int x[MAX_N + 1][MAX_M + 1];
int y[MAX_N + 1][MAX_M + 1];

int z[50][MAX_M];
int sum = 0;

int main() {
	int n, m, s, d, e, f, g;
	while (true) {
		cin >> n >> m >> s;
		if ((n == 0 && m == 0) && s == 0) {
			break;
		}
		memset(x, 0, sizeof(x));
		memset(y, 0, sizeof(y));
		memset(z,0,sizeof(z));

		if(m<s-((n*n)-2)*((n*n)-1)/2){
			memset(y, 0, sizeof(y));
			for (int i = 1; i <= m; i++) {
				x[i][i] = 1;
			}
			for (int i = 2; i <= n*n; i++) {
				d = s / (n*n - i + 1);
				e = min(m, d);
				f = s*i / (n*n) + i - n * n;
				g = (i - 2)*(i - 1) / 2;
				for (int j = i - 1; j <= e; j++) {
					for (int k = j + g; k <= f; k++) {
						for (int l = j + 1; l <= e; l++) {
							y[l][k + l] += x[j][k];
						}
					}
				}
				y[2000][3000] = 0;
				for (int j = i; j <= e; j++) {
					for (int k = j; k <= s; k++) {
						x[j][k] = y[j][k] % 100000;
						y[j][k] = 0;
					}
				}
				y[0][0] = 0;
			}
			sum=0;
			for (int i = 0; i <= m; i++) {
				sum += x[i][s];
				sum %= 100000;
			}
		}

		else{
			z[0][0]=1;
			for(int i=1;i<=n*n;i++){
				d=n*n-i+1;
				for(int j=0;j<=s;j++){
					e=0;
					while(j+e*d<=s){
						z[i][j+e*d] += z[i-1][j];
						z[i][j+e*d] %= 100000;
						e++;
					}
				}
			}
			sum=z[n*n][s-((n*n)+1)*(n*n)/2]%100000;
		}

		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 48668