akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
vector<PL> ab, only;
map<ll, ll> cnt, onlycnt;

signed main() {
    cin >> N;
    REP(i, N) {
        LCIN(A, B);
        ab.emplace_back(A, i);
        ab.emplace_back(B, i);
        only.emplace_back(A, 0);
        only.emplace_back(B, 1);
    }
    sort(All(ab));
    sort(All(only));
    ll ans = 0;
    bool two = false;
    REP(i, N) {
        ans += ab[i].first;
        if(++cnt[ab[i].second] == 2) {
            two = true;
        }
    }
    REP(i, N) if(++onlycnt[only[i].second] == N) {
        cout << ans << "\n";
        return 0;
    }
    if(!two) {
        ans -= ab[N - 1].first;
        if(ab[N].second == ab[N - 1].second)
            ans = min(ans - ab[N - 2].first + ab[N - 1].first + ab[N].first,
                      ans + ab[N + 1].first);
        else
            ans += ab[N].first;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 14684
import java.util.Scanner;


public class Main {
	
	public static int count(int[] sorted, int[] intSet) {
		
		int result = 0;
		
		for(int i = 0; i < intSet.length; i++) {
			
			for(int j = 0; j < sorted.length; j++) {
				
				if(intSet[i] == sorted[j]) {
					result++;
					break;
				}
			}
		}
		return result;
	}

	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		
		int numSorted = in.nextInt();
		int[] sorted = new int[numSorted];
		
		for(int i = 0; i < numSorted; i++) {

			sorted[i] = in.nextInt();

		}
		
		int setNum = in.nextInt(); 
		int[] intSet = new int[setNum];

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

			intSet[j] = in.nextInt();

		}

		int result = count(sorted, intSet);

		System.out.println(result);


		in.close();
		
	}

}



Measured memory_bytes: 40544
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text.RegularExpressions;
using System.Threading;

namespace Atcoder
{
	class Program
	{
		//string s = Console.ReadLine();
		//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		//int H = intArray[0];
		//int W = intArray[1];
		//int N = int.Parse(Console.ReadLine());
		//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
		//Boolean ok = false;

		//Console.WriteLine(ans);
		//Console.WriteLine("Yes");
		//Console.WriteLine("No");
		//Console.ReadKey();
		//Console.WriteLine(cnt);

		//string[] strArray = Console.ReadLine().Split(' ').ToArray();
		//string S = strArray[0];
		//string T = strArray[1];
		static void Main(string[] args)
		{
			string S = Console.ReadLine();
			int ans = 0;
			int len = S.Length;
			int half = len / 2;
			for(int i = 0;i < half; i++)
            {
				if (S[i] != S[len - i - 1])
					ans++;
            }
			Console.WriteLine(ans);
		}

		/// <summary>
		/// 回文
		/// </summary>
		/// <param name="Target"></param>
		/// <param name="len"></param>
		/// <returns></returns>
		static bool Palindrome(string Target , int len)
        {
			bool yes = true;

			for(int i = 0;i < len; i++)
            {
				if(Target[i] != Target[len - 1 - i])
                {
					yes = false;
					break;
                }
            }
			return yes;
        }

		/// <summary>
		/// アナグラム
		/// </summary>
		/// <param name="word1"></param>
		/// <param name="word2"></param>
		/// <returns></returns>
		static bool IsAnagramOf(string word1, string word2)
		{
			return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
		}
		/// <summary>
		/// 最小公倍数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Lcm(BigInteger a, BigInteger b)
		{
			return a * b / Gcd(a, b);
		}

		/// <summary>
		/// 最大公約数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Gcd(BigInteger a, BigInteger b)
		{
			if (a < b)
				// 引数を入替えて自分を呼び出す
				return Gcd(b, a);
			while (b != 0)
			{
				var remainder = a % b;
				a = b;
				b = remainder;
			}
			return a;
		}
	}
}

Measured memory_bytes: 25940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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 main () {
  int n = in();
  cout << 111*dup(n,111) << endl;
  return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    s, T = LS()
    A, B = LI()
    U = S()
    if U == s:
        print(A-1, B)
    else:
        print(A, B-1)

main()



Measured memory_bytes: 7724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    /*ll k, a, b;
    cin >> k >> a >> b;
    if(b - a <= 2) {
        cout << 1 + k << endl;
        return 0;
    }
    ll count = 1; // クッキーの枚数。
    ll money = 0;
    rep(i, k) {
        if(money != 0) {
            count += b;
            money--;
            continue;
        }
        if(i == k - 1) {
            count++;
            continue;
        }
        if(count < a && money == 0 ) {
            count++;
            continue;
        }
        if(count >= a && i + 1 < k - 1) {
            money++;
            count -= a;
            continue;
        }
        
        
        
    }
    cout << count << endl;*/
    ll k, a, b;
    cin >> k >> a >> b;
    if(b - a <= 2 || a - 1 > k) {
        cout << 1 + k << endl;
        return 0;
    }
    k -= a - 1;
    ll count = a;
    ll n = floor(k / 2);
    rep(i, n) count += b - a;
    if(k % 2 == 1) count++;
    cout << count << endl;
    // cout << n << endl;
}

Measured memory_bytes: 3604
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , bytes ) => { read_value ! ( $ next , String ) . into_bytes ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
#[allow(dead_code)]
pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer)
}
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) } ; }
#[allow(dead_code)]
fn main() {
    input!{
        n: usize,
        a: u64,
        b: u64,
        p: [u64; n],
    }
    let mut p = p;
    p.sort();

    let mut one = 0;
    let mut two = 0;
    let mut three = 0;
    for pp in p {
        if pp <= a {
            one += 1;
        } else if pp > a && pp <= b {
            two += 1;
        } else {
            three += 1;
        }
    }
    println!("{}", min(one, min(two, three)));
}

Measured memory_bytes: 4352
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        String[] a = new String[H];
        int[] cnt = new int[26];
        for(int i = 0; i < H; i++){
            a[i] = sc.next();
            for(int j = 0; j < W; j++){
                cnt[(int)(a[i].charAt(j)-'a')]++;
            }
        }
        sc.close();

        int cnt4=0, cnt2=0, cnt1=0;
        for(int i = 0; i < 26; i++){
            cnt4 += cnt[i]/4;
            cnt2 += cnt[i]/2;
            if(cnt[i]%2 != 0)
                cnt1++;
        }
        if(H%2 == 0 && W%2 == 0){
            if(cnt4 == H*W/4)
                System.out.println("Yes");
            else
                System.out.println("No");
        } else if(H%2 != 0 && W%2 != 0){
            if(cnt1 == 1 && cnt4 >= (H-1)*(W-1)/4)
                System.out.println("Yes");
            else
                System.out.println("No");
        } else if(H%2 == 0 && W%2 != 0){
            if(cnt1 == 0 && cnt4 >= H*(W-1)/4)
                System.out.println("Yes");
            else
                System.out.println("No");
        } else {
            if(cnt1 == 0 && cnt4 >= (H-1)*W/4)
                System.out.println("Yes");
            else
                System.out.println("No");
        }
    }
}

Measured memory_bytes: 23380
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;

struct ST {
	vector<ll> seg, lazy;   //seg木と遅延
	int size;

	ST(int n) {
		//seg木のサイズは(nが入るような２のべき乗のサイズ)*2
		size = 1;
		while (size < n) size *= 2;
		seg.resize(size * 2);
		lazy.resize(size * 2, -1e9);  //-1e9で初期化
	}

	//遅延評価
	void push(int k, int l, int r) {
		if (lazy[k] != -1e9) {    //遅延があるなら
								//ノードkは対応する区間の葉の総和
			seg[k] = lazy[k] * (r - l);     //ノードkを更新
											//区間[l,r)がすべてlazy[k](=v)になるから
			if (r - l > 1) {    //子ノードがあるなら
				lazy[k * 2 + 1] = lazy[k];  //ノードkの子(左)に伝搬
				lazy[k * 2 + 2] = lazy[k];  //ノードkの子(右)に伝搬
			}
			lazy[k] = -1e9;                   //ノードkは伝搬し終わった
		}
	}

	//x+y
	ll merge(ll x, ll y) {
		return x + y;
	}

	//[a,b)をvに
	//[l,r)はノードが持つ区間
	void update(int a, int b, ll v, int k, int l, int r) {
		//ノードkに対して遅延があるかもしれない
		//その時ノードkは更新される
		push(k, l, r);

		if (r <= a || b <= l) return;   //[a,b)がノードkの区間[l,r)と交差しない
		if (a <= l && r <= b) {         //[a,b)がノードkを完全に含む
			lazy[k] = v;    //ノードkの区間[l,r)はすべてvになったという情報
			push(k, l, r);  //子に伝搬
							//ノードkを更新
		}
		else {                        //その他
									  //左の子をupdate
			update(a, b, v, k * 2 + 1, l, (l + r) / 2);
			//右の子をupdate
			update(a, b, v, k * 2 + 2, (l + r) / 2, r);

			seg[k] = merge(seg[k * 2 + 1], seg[k * 2 + 2]); //ノードkを更新
		}
	}

	void update(int a, int b, ll v) {
		update(a, b, v, 0, 0, size);
	}

	//[a,b)の総和
	//[l,r)はノードが持つ区間
	ll query(int a, int b, int k, int l, int r) {
		//ノードkに対して遅延があるかもしれない
		//その時ノードkは更新される
		push(k, l, r);

		if (r <= a || b <= l) return 0;             //[a,b)がノードkの区間[l,r)と交差しない時0を返す
		if (a <= l && r <= b) return seg[k];        //[a,b)がノードkを完全に含む時そのノードの値を返す
													//左の子の総和
		ll x = query(a, b, k * 2 + 1, l, (l + r) / 2);
		//右の子の総和
		ll y = query(a, b, k * 2 + 2, (l + r) / 2, r);

		return merge(x, y);//子の和を返す
	}

	ll query(int a, int b) {
		return query(a, b, 0, 0, size);
	}
};

struct KOJI
{
	int S,T,X;

	bool operator<(const KOJI& r)const
	{
		return X<r.X;
	}
};

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

	vector<KOJI>koji;
	for (int i = 0; i < N; i++)
	{
		int s,t,x;cin>>s>>t>>x;
		koji.push_back(KOJI({s,t,x}));
	}
	sort(koji.begin(), koji.end());
	reverse(koji.begin(), koji.end());

	ST st(Q);
	st.update(0, Q, -1);

	vector<int>D(Q);
	for (int i = 0; i < Q; i++)
	{
		cin>>D[i];
	}

	for (int i = 0; i < N; i++)
	{
		int kl,kr;

		int lv = koji[i].S - koji[i].X;
		int rv = koji[i].T - koji[i].X;
		//cerr<<koji[i].S<<" "<<koji[i].T<<" "<<koji[i].X<<endl;
		int l,r;

		l = 0, r = Q;
		while (l < r)
		{
			int m = (l+r)/2;

			if(D[m] >= lv)r = m;
			else l = m+1;
		}

		kl = l;

		l = 0, r = Q;
		while (l < r)
		{
			int m = (l + r) / 2;

			if (D[m] >= rv)r = m;
			else l = m + 1;
		}

		kr = r;

		//cerr<<kl<<" "<<kr<<endl;

		st.update(kl, kr, koji[i].X);

	}

	for (int i = 0; i < Q; i++)
	{
		cout<<st.query(i,i+1)<<endl;
	}
	
	return 0;
}

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

//GCD,LCM
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 N,A[200010]={},cnt=1,f=0;
    cin>>N;

    for(int i=1;i<=N;i++){
        cin>>A[i];
        if(A[i]==cnt){
            cnt++;
            f=1;
        }
    }

    if(f==0){
        cout<<-1<<endl;
    }else{
        cout<<N-(cnt-1)<<endl;
    }

    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a_0 = list(map(int, input().split()))
a_1 = list(map(int, input().split()))

max_i = 0
max_c = 0
for i in range(n):
    c = sum(a_0[:i+1])+sum(a_1[i:])
    if c > max_c:
        max_i = i
        max_c = c
print(max_c)


Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

//x,y structure
typedef struct{
  double x;
  double y;
}XY;

bool flagfirst=true;
bool test=true;

int counter=0;

//function kochCurve
void kochCurve(XY p1,XY p2,int n){
  XY s,u,t;
  //calculate x,y

  s.x=(2*p1.x+p2.x)/3;
  s.y=(2*p1.y+p2.y)/3;
  t.x=(p1.x+2*p2.x)/3;
  t.y=(p1.y+2*p2.y)/3;
  u.x=(t.x-s.x)*cos(M_PI/3)-(t.y-s.y)*sin(M_PI/3)+s.x;
  u.y=(t.x-s.x)*sin(M_PI/3)+(t.y-s.y)*cos(M_PI/3)+s.y;

  //print to 8 decimal places
  if(flagfirst==true) {
    printf("%.8f  %.8f\n",p1.x,p1.y);
    flagfirst=false;
  }
 
  if(n>0){
    kochCurve(p1,s,n-1);
    printf("%.8f  %.8f\n",s.x,s.y);
    kochCurve(s,u,n-1);
    printf("%.8f  %.8f\n",u.x,u.y);   
    kochCurve(u,t,n-1);
    printf("%.8f  %.8f\n",t.x,t.y); 
    kochCurve(t,p2,n-1);

  
  
 
  } 
  

}

int main(){

  int n;
  XY p1,p2;

  //load number
  cin >>n;

  //initialize
  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;


  //execute kochCurve
  kochCurve(p1,p2,n);
 
  printf("%.8f  %.8f\n",p2.x,p2.y);   

  return 0;

}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;
    if (N % 2 == 1){
        cout << "No" << endl;
        return 0;
    }
    if (S.substr(0,N/2) == S.substr(N/2,N)){
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#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 Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#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,Q,A,B,L,R;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N;
    cout<<N*N<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    if a[i]%2 == 0:
        if a[i]%3 == 0 or a[i]%5 == 0:
            pass
        else:
            print("DENIED")
            exit()
print("APPROVED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  //input
  int d,t,s;cin >> d >> t >> s;
  bool ans;
  
  //compute
  if(d % s == 0){
           ans = ((d / s) <= t);
         }else{
           ans = ((d / s) < t);
         }
 
  //output
  if(ans == true){
           cout << "Yes" << endl;
         }else{
           cout << "No" << endl;
         }
  
}

Measured memory_bytes: 3532
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define mod (int)1000000007
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = DBL_EPSILON;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline int gcd(int a, int b) {
	while (b) {
		int c = a;
		a = b; b = c % b;
	}
	return a;
}
inline int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
bool isprime(int n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
int mypow(int a, int b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int modpow(int a, int b, int m = mod) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	int memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
int a[3][3], n, b;
signed main() {
	rep(i, 3) {
		rep(j, 3)cin >> a[i][j];
	}
	cin >> n;
	rep(i, n) {
		cin >> b;
		rep(j, 3) {
			rep(k, 3) {
				if (a[j][k] == b)a[j][k] = 0;
			}
		}
	}
	if (!a[0][0] && !a[0][1] && !a[0][2])puts("Yes");
	else if (!a[0][0] && !a[1][0] && !a[2][0])puts("Yes");
	else if (!a[1][0] && !a[1][1] && !a[1][2])puts("Yes");
	else if (!a[0][1] && !a[1][1] && !a[2][1])puts("Yes");
	else if (!a[2][0] && !a[2][1] && !a[2][2])puts("Yes");
	else if (!a[0][2] && !a[1][2] && !a[2][2])puts("Yes");
	else if (!a[0][0] && !a[1][1] && !a[2][2])puts("Yes");
	else if (!a[0][2] && !a[1][1] && !a[2][0])puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main() {

    int X,max=1;
    cin >> X;

    for (int i = 2; i < X; i++) {
        for (int j = 2;; j++) {
            if (pow(i, j) == X) {
                cout << pow(i, j) << endl;
                return 0;
            }
            else if (pow(i, j) > max&&pow(i, j) < X) {
                max = pow(i, j);
            }
            else if (pow(i, j) > X)break;
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
	int n,m,t;
	cin>>n>>m>>t;int f=0;
	rep(i,n+1)rep(j,m+1){
		if(i*j+(n-i)*(m-j)==t) f=1;
	}
	cout<<(f?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a <= k)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
}


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

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define Sort(a)   sort(a.begin(), a.end())
const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    int l; cin >> l;
    
    long double div = l / 3.0;

    long double ans;

    if(div * 3 == l) ans = div * div * div;
    else if(div * 3 > l) ans = div * div * (div - (0.000001));
    else                 ans = div * div * (div + (0.000001));

    cout << fixed << setprecision(12) << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
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> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    for (ll i = 0;i<5;i++) {
        ll a;
        cin >> a;
        if (a==0) {
            cout << i+1 << endl;
            break;
        }
    }
}

Measured memory_bytes: 3564
N, K = map(int, input().split())
A = [int(i)for i in input().split()]

x = 0
for l in range(N-1):
    for r in range(l+1, N):
        if A[l] > A[r]:
            x += 1
count = K * x

AA = A + A
y = 0
for l in range(2 * N - 1):
    for r in range(l+1, 2*N):
        if AA[l] > AA[r]:
            y += 1
# 同じ数列の中にあるものを除く
y -= 2 * x

# K_C_2 K個の中から2個選ぶ
count += K * (K - 1) // 2 * y

mod = 10 ** 9 + 7
result = int(count % mod)
print(result)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  ll N, A;
  cin >> N >> A;
  vector<ll> x(N);
  rep(i, N) {
    cin >> x[i];
  }

  vector<vector<vector<ll>>> dp(
      N + 1, vector<vector<ll>>(N + 1, vector<ll>(N * 50 + 1)));

  dp[0][0][0] = 1;

  rep(i, N) {
    rep(j, N + 1) {
      rep(k, N * 50 + 1) {
        if (j < N && k + x[i] <= N * 50)
          dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
        dp[i + 1][j][k] += dp[i][j][k];
      }
    }
  }

  ll ans = 0;
  repp(j, 1, N) {
    ans += dp[N][j][j * A];
  }

  cout << ans << endl;
}

Measured memory_bytes: 52224
#include<bits/stdc++.h>
#include<queue>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll val = sqrt(n);
    ll ans = 1;
    for(ll i = 0;i<=val;i++){
        if(i*i <= n){
            ans = i*i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final long N = sc.nextLong();
			
			long answer = 0;
			for(long i = 1; i * i <= N; i++) {
				final long div = (N - i) / i;
				if(div <= 0) { break; }
				
				//if(div * i + i == N) {
				if(N / div == N % div) {
					//System.out.println(i + " * " + (div) + " + " + i + " = " + N);
					answer += div;
				}
			}
			for(long i = 1; i * i < N; i++) {
				if(N / i == N % i) {
					answer += i;
				}
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
//#pragma GCC diagnostic error "-Wconversion"
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);

  int n; cin >> n;
  vector<int> nums(n); rep(i, n) cin >> nums[i];

  ll ans = 0;
  //string ans = "No";

  ans = INF;
  rep(i, n){
    auto a = factor(nums[i]);
    ans = min(ans, a[2]);
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fore(x,a,b) for(int x=a, qwerty=b; x<qwerty; x++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define fst first
#define snd second
using namespace std;
typedef long long ll;

const int V=30001;
vector<int> can[3][2];
int n;

int main(){
    cin >> n;
    fore(x,2,V)if(x%3==0||x%2==0)can[x%3][x%2].pb(x);
    vector<int> ans;
    if(n==3){cout<<"2 5 63\n";exit(0);}
    ans.pb(can[0][1].back());can[0][1].pop_back();
    ans.pb(can[0][1].back());can[0][1].pop_back();
    ans.pb(can[1][0].back());can[1][0].pop_back();
    ans.pb(can[2][0].back());can[2][0].pop_back();
    while(SZ(can[1][0]) && SZ(ans)+2<=n){
        ans.pb(can[1][0].back());can[1][0].pop_back();
        ans.pb(can[2][0].back());can[2][0].pop_back();
    }
    while(SZ(can[0][1]) && SZ(ans)+2<=n){
        ans.pb(can[0][1].back());can[0][1].pop_back();
        ans.pb(can[0][1].back());can[0][1].pop_back();
    }
    while(SZ(can[0][0]) && SZ(ans)<n){
        ans.pb(can[0][0].back());can[0][0].pop_back();
    }
    fore(x,0,n)cout<<ans[x]<<" \n"[x+1==n];
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
                using namespace std;
                typedef long long ll;
                #define INPUT()              freopen("input.txt", "r", stdin)
                #define OUTPUT()             freopen("output.txt", "w", stdout)
                #define F                    first
                #define S                    second
            //Templatefunctions
                template<typename T>T gcd(T x, T y) { if (y == 0)return x; else return gcd(y, x%y);}
                template <class T> T euclideanDistance(T x1 , T x2 , T y1 , T y2){return sqrt(( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ));}
                template <class T> T digitSum(T n){T sum = 0;while(n > 0)sum += n % 10,n /= 10;return sum;}
            //datatypes
                typedef long long int ll;
                typedef unsigned long long int ull;
                typedef long double ld;
            //constants
                const double INF = 1e+9;
                const double INFLL = 1e+18;
                const double EPS = 1e-9;
                const double PI = acos(-1);
                const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
                       //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
                       //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
                const int dx[] = {0 , 1 , 0 , -1};
                const int dy[] = {1 , 0 , -1 , 0};
            //helpers
                //#define MOD         1000000007LL
                #define MAX         1000005
                const ll MOD = 1000000000 + 7;
                int arr[MAX];
                char str[MAX+10];
            //Global Variables
                int price[MAX] = {0 , 1 , 5 , 8 , 9 , 10 , 17 , 17 , 20 , 24 , 30};
                int dp[MAX],n;

                int main()
                {
                   ll s,c;
                   scanf("%lld%lld",&s,&c);
                   ll ans = 0;
                   if(c < s * 2 || c < s)
                   {
                        ans = c / 2;
                   }else
                   {
                        ans += s;
                        c -= s * 2;
                        ans += c / 4;
                   }
                   printf("%lld\n",ans);
                }


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

for i in range(n):
    v = l[i]
    j = i - 1
    while j >= 0 and l[j] > v:
        l[j+1] = l[j]
        j -= 1
    l[j+1] = v
    print(" ".join(map(str, l)))

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

#ifdef SG
	#include <debug.h>
#else
	template<typename T> struct outputer;
	struct outputable {};
	#define PRINT(...)
	#define OUTPUT(...)
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
	#define fbegin(...)
	#define fend
	#define pbegin(...)
	#define pend
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb emplace_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef int64_t ll;
typedef uint64_t ull;
typedef uint32_t ui;
typedef uint16_t us;
typedef uint8_t uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 100000;

struct Input {
	int n;
	int a[N];
	
	bool read () {
		if (!(cin >> n)) {
			return 0;
		}
		forn (i, n) {
			scanf("%d", &a[i]);
		}
		return 1;
	}

	void init (const Input &input) {
		*this = input;
	}
};

struct Data: Input {
	bool ans;
	
	void write () {
		puts(ans ? "Yes" : "No");
	}
};


namespace Main {
	
	struct Solution: Data {
		
		bool check (int k) {
			int cnt0 = 0, cnt1 = 0;
			forn (i, n) {
				if (a[i] == k) {
					cnt0++;
				} else if (a[i] == k - 1) {
					cnt1++;
				} else {
					return 0;
				}
			}
			debug(mt(n, k, cnt0, cnt1));
			if (cnt1 > k) {
				return 0;
			}
			int l = k - cnt1;
			debug(l);
			if (cnt0 && !l) {
				return 0;
			}
			if (2 * l > cnt0) {
				return 0;
			}
			debug(1);
			return 1;
		}
		
		void solve () {
			ans = check(a[0]) || check(a[0] + 1);
		}
		
		void clear () {
			*this = Solution();
		}
	};
}


Main::Solution sol;

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);

	#ifdef SG
		freopen((problemname + ".in").c_str(), "r", stdin);
//		freopen((problemname + ".out").c_str(), "w", stdout);
		while (sol.read()) {
			sol.solve();
			sol.write();
			sol.clear();
		}
	#else
		sol.read();
		sol.solve();
		sol.write();
	#endif
	
	/*
	int t;
	cin >> t;
	forn (i, t) {
		sol.read();
		sol.solve();
		sol.write();
		sol.clear();
	}
	*/
	
	return 0;
}


Measured memory_bytes: 640
n = input()
balls = list(input())

backindex = len(balls) - 1
frontindex = 0
actions = 0

while frontindex < backindex:
  if balls[frontindex] == 'W':
    while backindex > frontindex:
      if balls[backindex] == 'R':
        balls[frontindex] = 'R'
        balls[backindex] = 'W'
        actions += 1
        break
      backindex -= 1
  frontindex += 1

print(actions)

Measured memory_bytes: 10576
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int solve(vector<int> cols,int st){
    int l=st,r=st;
    for(int ix=0;;ix++){
        int ncol=cols[l];
        int befl=l,befr=r;
        for(;l>=0;l--){
            if(cols[l]!=ncol){
                l++;
                break;
            }
        }
        if(l<0)l=0;
        for(;r<cols.size();r++){
            if(cols[r]!=ncol){
                r--;
                break;
            }
        }
        if(r>=cols.size())r=cols.size()-1;
        int va=(r-befr)+(befl-l);
        if(befl==befr)va+=1;
        else va+=2;
        if(va==cols.size())return 0;
        if(va<4){
            r=befr;
            l=befl;
            break;
        }
        l--;
        r++;
    }
    return cols.size()-(r-l-1);
}
int main(){
    for(;;){
        int n;
        scanf("%d",&n);
        if(n==0)break;
        vector<int> cols(n);
        for(int i=0;i<n;i++){
            scanf("%d",&cols[i]);
            cols[i]-=1;
        }
        int mi=n;
        for(int i=0;i<n;i++){
            vector<bool> able(3,true);
            able[cols[i]]=false;
            for(int j=0;j<3;j++){
                if(able[j]){
                    int te=cols[i];
                    cols[i]=j;
                    mi=min(mi,solve(cols,i));
                    cols[i]=te;
                }
            }
        }
        printf("%d\n",mi);
    }
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

vector<int> chair;

int set_chair(int i)
{
  cout << i << endl;
  string state;
  cin >> state;
  if (state == "Male")
    chair[i] = 1;
  else if (state == "Female")
    chair[i] = -1;
  else
    chair[i] = 0;

  return chair[i];
}

int main()
{
  int N;
  cin >> N;
  chair.resize(N);
  if (set_chair(0) == 0)
  {
    return 0;
  }

  int l = 0, r = N;
  while (l - r != 1)
  {
    int c = (l + r) / 2;
    int state = set_chair(c);
    if (state == 0)
      return 0;

    bool is_equal = chair[c] == chair[l];
    bool length_is_even = (l - c) % 2 == 0;
    bool is_ok = is_equal xor length_is_even;
    if (is_ok)
      r = c;
    else
      l = c;
  }

  set_chair(l);
  return 0;
}

Measured memory_bytes: 1236
# 累積和(2次元)を用いた解法
from itertools import accumulate
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,M,Q,*lr = map(int, read().split())

    LR = [[0]*(N+1) for _ in range(N+1)]
    query = []
    for i, (l, r) in enumerate(zip(*[iter(lr)]*2)):
        if i < M:
            LR[l][r] += 1
        else:
            query.append((l, r))
    
    for i in range(1,N+1):
        LR[1][i] += LR[1][i-1]
        LR[i][1] += LR[i-1][1]
    
    for i in range(2, N+1):
        for j in range(2,N+1):
            LR[i][j] += LR[i-1][j] + LR[i][j-1] - LR[i-1][j-1]
    
    for p, q in query:
        ans = LR[q][q] - LR[p-1][q] - LR[q][p-1] + LR[p-1][p-1]
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 123888
class Rabbit
  attr :n
  attr :like

  def initialize(n)
    @n = n
    @like = false
  end

  def set_like
    @like = true
  end
end

n = gets.to_i

rabbits = []
rabbits = gets.split(' ').map { |r| Rabbit.new(r.to_i) }

rabbits.each_with_index.each do |r,i|
  r.set_like if rabbits[rabbits[i].n - 1].n == i + 1
end

puts rabbits.select {|r| r.like == true }.length / 2


Measured memory_bytes: 13068
#include<bits/stdc++.h>
using namespace std ;
const int maxn = 1e5 + 10 ;
string s ;
int main()
{
	cin >> s ;
	bool b  = 1 ;
	if ( s[0] != '1' || s[s.size()-1] != '0' ) 
		b = false ;
	for ( int i = 0; i< s.size()-1 ; i++)
		if ( s[i] != s[s.size()-2-i] ) 
			b = false ;
	if ( !b ) 
		cout << -1<< endl;
	else
	{
		int x = 1;
		for ( int i = 0 ; i<s.size()-1 ; i++)
		{
			cout << x << " " << i+2 << "\n" ;
		if ( s[i] == '1' ) 
			x = i+ 2 ;
		}
	}

}

Measured memory_bytes: 1664
n = int(raw_input().split()[0])

o1 = [3,5,7]
arr = [n]
ans = 0
def check(num):
    l = len(str(num))
    s = []
    for i in range(l):
        if str(num)[i] not in s:
            s.append(str(num)[i])
    if len(s) == 3:
        return True
    else:
        return False

for i in range(8):
    o2 = []
    for num in o1:
        new1 = num*10+3
        new2 = num*10+5
        new3 = num*10+7
        o2.append(new1)
        o2.append(new2)
        o2.append(new3)
        if check(new1):
            arr.append(new1)
            if n == new1:
                ans += 1
        if check(new2):
            arr.append(new2)
            if n == new2:
                ans += 1
        if check(new3):
            arr.append(new3)
            if n == new3:
                ans += 1
    o1 = o2
arr.sort()
print arr.index(n) + ans

Measured memory_bytes: 3844
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define int ll
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=12;
char S[N];
int ans,n,b[N];
int check(){
	int sum=0,now=0;
	for(int i=1;i<=n;i++){
		now=now*10+(S[i]-'0');
		if(b[i]){sum+=now;now=0;}
	}
	sum+=now;
	return sum;
}
void dfs(int now){
	if(now==n){ans+=check();return;}
	dfs(now+1);
	b[now]=1;dfs(now+1);b[now]=0;
}
signed main(){
	scanf("%s",S+1);n=strlen(S+1);
	dfs(1);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
st = 0
la = N - 1
result = 0

while(st < la):
  if S[st] == 'x' and S[la] == 'x':
    st += 1
    la -= 1
    continue
  if S[st] != 'x' and S[la] == 'x':
    la -= 1
    result += 1
  elif S[st] == 'x' and S[la] != 'x':
    st += 1
    result += 1
  elif S[st] == S[la]:
    st += 1
    la -= 1
  else:
    result = -1
    break

print(result)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i > 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;

int main() {
  ll s, c, anser = 0;
  cin >> s >> c;
  if (c - (s * 2) >= 0) {
    anser = s;
    c -= s * 2;
    anser += c / 4;
  } else if ( c == 0 ) {
    anser = 0; 
  } else {
    c /= 2;
    anser = c; 
  }
  cout << anser << endl;
  return 0;
}

Measured memory_bytes: 892
#include <stdio.h>
int main(void) {
	int R, B, W, G;
	scanf("%d", &R);
	scanf("%d", &B);
	scanf("%d", &W);
	scanf("%d", &G);
	R = R + B + W + G;
	printf("%d\n", R);
	return 0;
}


Measured memory_bytes: 2760