akhauriyash/Code-Regression huggingface dataset:
//In the Name of God
//Ya Ali

#include<bits/stdc++.h>

#define err(A) cout<<#A<<" = "<<(A)<<endl

using namespace std;

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

  string s;
  cin>>s;

  if(s[0]==s[s.size()-1] xor (s.size()&1))
    cout<<"First"<<endl;
  else
    cout<<"Second"<<endl;
    
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n, k;
  cin >> n >> k;
  int ans = 0;
  int tmp = 0;
  REP(i,n){
    cin >> tmp;
    ans += 2*min(tmp, k - tmp);
  }
  cout << ans << endl;


}


Measured memory_bytes: 256
/*************************************************************************
    > File Name: aoj0033.cpp
    > Author:    WArobot 
    > Blog:      http://www.cnblogs.com/WArobot/ 
    > Created Time: 2017??´06???21??\ ????????? 19??¶29???08?§?
 ************************************************************************/

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

int n , ball[10] , left_back , last_lb , right_back , last_rb ;
bool ok;

void DFS(int num){
	if( ok || num > 10 )	return;
	if( num == 10 ){
		ok = true;	return;
	}
	if( ball[num] >= left_back ){
		last_lb = left_back;
		left_back = ball[num];
		DFS(num+1);	
		left_back = last_lb;
	}
	if( ball[num] >= right_back ){
		last_rb = right_back;
		right_back = ball[num];
		DFS(num+1);	
		right_back = last_rb;
	}
}
int main(){
	scanf("%d",&n);
	while(n--){
		for(int i = 0 ; i < 10 ; i++){
			scanf("%d",&ball[i]);
		}
		ok = false;	left_back = right_back = last_lb = last_rb = 0;
		DFS(0);
		if(ok)	printf("YES\n");
		else	printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 3128
N, M=map(int, input().split())
sc=[list(map(int, input().split())) for i in range(M)]

num=[-1]*N
for i in range(M):
  if num[sc[i][0]-1]==-1:
    num[sc[i][0]-1]=sc[i][1]
  else:
    if num[sc[i][0]-1]!=sc[i][1]:
      print(-1)
      exit()
    else:
      pass
    
if N==1:
  if num[0]==-1:
    print(0)
  else:
    print(num[0])
  exit()
  
if num[0]==0:
  print(-1)
  exit()
  
if num[0]==-1:
  num[0]=1
  
for i in range(1, N):
  if num[i]==-1:
    num[i]=0
    
num=[str(num[i]) for i in range(N)]
    
print(''.join(num))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, h);

    int y = h[0]-1;
    for(int i = 1; i < n; i ++){
        if(h[i] < y){
            Cout("No");
            return 0;
        }
        Maxi(y, h[i]-1);
    }
    Cout("Yes");
}



Measured memory_bytes: 640
N = int(input())
leng = list(map(int, input().split( )))
count = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    if leng[i] == leng[j]:continue
    for k in range(j+1, N):
      if leng[i] == leng[k] or leng[j] == leng[k]:continue
      L = [leng[i],leng[j],leng[k]]
      if max(L) < sum(L)-max(L):
        count += 1
print(count)
        
      

  
  

  

Measured memory_bytes: 9140
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		int k = sc.nextInt(), k2 = k * 2, k4 = k * 4;
		int[][] bb = new int[k4][k4];
		int[][] ww = new int[k4][k4];
		while (n-- > 0) {
			int i = sc.nextInt() % k2;
			int j = sc.nextInt() % k2;
			char c = sc.next().charAt(0);
			if (c == 'B') {
				bb[i][j]++;
				bb[k2 + i][j]++;
				bb[i][k2 + j]++;
				bb[k2 + i][k2 + j]++;
			} else {
				ww[i][j]++;
				ww[k2 + i][j]++;
				ww[i][k2 + j]++;
				ww[k2 + i][k2 + j]++;
			}
		}
		for (int i = 0; i < k4; i++)
			for (int j = 1; j < k4; j++) {
				bb[i][j] += bb[i][j - 1];
				ww[i][j] += ww[i][j - 1];
			}
		for (int i = 1; i < k4; i++)
			for (int j = 0; j < k4; j++) {
				bb[i][j] += bb[i - 1][j];
				ww[i][j] += ww[i - 1][j];
			}
		int ans = 0;
		for (int i_ = 0; i_ < k2; i_++)
			for (int j_ = 0; j_ < k2; j_++) {
				int i, j, cnt = 0;
				i = i_; j = j_;
				cnt += bb[i + k][j + k] - bb[i][j + k] - bb[i + k][j] + bb[i][j];
				i = i_ + k; j = j_ + k;
				cnt += bb[i + k][j + k] - bb[i][j + k] - bb[i + k][j] + bb[i][j];
				i = i_ + k; j = j_;
				cnt += ww[i + k][j + k] - ww[i][j + k] - ww[i + k][j] + ww[i][j];
				i = i_; j = j_ + k;
				cnt += ww[i + k][j + k] - ww[i][j + k] - ww[i + k][j] + ww[i][j];
				ans = Math.max(ans, cnt);
			}
		println(ans);
	}
}


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

  //mp.reserve(1024);
  //mp.max_load_factor(0.25);
int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
		ll c=1,max1=a[0];
	for(ll i=1;i<n;i++){
		if(a[i]<max1){
			c++;
			max1=a[i];
	}
	}
	cout<<c<<endl;
    return 0; 
} 


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

int main() {
  string s, t;
  int c;
  cin >> s >> t;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i)) {
      c += 1;
    }
  }
  
  cout << c << endl;
  
  return 0;
}


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

int main() {
  int a[3];
  rep(i,3) cin >> a[i];
  sort(a, a+3);
  int val = 2*a[2]-a[1]-a[0];
  int ans = 0;
  if(val%2==0) ans = val/2;
  else ans = (val+3)/2;
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] h = new int[n];
	for (int i=0; i<n; i++) h[i] = sc.nextInt();
	int mae = h[0];
	int max = 0;
	int count = 0;
	for (int i=1; i<n; i++) {
	    if (h[i] <= mae) {
		mae = h[i];
		count++;
		if (count > max)
		    max = count;
	    } else {
		mae = h[i];
		count = 0;
	    }
	}
	System.out.print(max);
    }
}


Measured memory_bytes: 59412
fun main(args: Array<String>){
    val N = nextInt()
    val L = listOfInt().sorted()
    val D = L.map { it.toDouble()}
    var ans = 0L
    for (a in 0 until N-2) {
        for (b in a+1 until N-1) {
            val ab = L[a] + L[b]
            val l = b + 1
            var r = D.binarySearch(element = ab.toDouble() - 0.1, fromIndex = l, toIndex = N - 1)
            if (r < 0) r = r.inv()
            if (ab > L[r]) r++
            val c = Math.max(0, r - l)
            ans += c
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

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

using namespace std;

int sm [200002];
int tt [200002];

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,C;
	cin >> N >> C;
	vector<int> s(N),t(N),c(N);
	rep(i,N)cin >> s[i] >> t[i] >> c[i];
	for(int i=1;i<=C;i++){
		for(int j=0;j<200002;j++)tt[j]=0;
		for(int j=0;j<N;j++)if(c[j]==i)tt[s[j]*2-1]++,tt[t[j]*2]--;
		for(int j=1;j<200002;j++)tt[j]+=tt[j-1];
		for(int j=0;j<200002;j++)if(tt[j]>0)sm[j]++;
	}
	int mx = 0;
	for(int j=0;j<200002;j++)if(mx<sm[j])mx=sm[j];
	cout << mx << endl;
}

Measured memory_bytes: 2944
import bisect

n=int(input())
opens=0
closes=0
ls=[]
rs=[]
for _ in range(n):
  s=input()
  cnt1=0
  cnt2=0
  for i in range(len(s)):
    if s[i]=='(':
      cnt1+=1
    else:
      if cnt1==0:
        cnt2+=1
      else:
        cnt1-=1
  if cnt2==0:
    opens+=cnt1
  elif cnt1==0:
    closes+=cnt2
  else:
    ls.append(cnt2)
    rs.append(cnt1)
ls=sorted(ls)
rs=sorted(rs)
lefts=sum(ls)
rights=sum(rs)
if opens-closes!=lefts-rights:
  print('No')
else:
  flag=False
  if len(ls)==0:
    flag=True
  for a in ls:
    if opens<a or closes<a+(rights-lefts):
      continue
    pos=bisect.bisect_right(rs,a+(rights-lefts))
    if pos!=0:
      flag=True
      break
  for b in rs:
    if opens<b+(lefts-rights) or closes<b:
      continue
    pos=bisect.bisect_right(ls,b+(lefts-rights))
    if pos!=0:
      flag=True
      break
  if flag==True:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 13964
use std::io;
fn get_parms() -> Vec<i32> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("stdin error");
    return buf
        .split_whitespace()
        .map(|x| x.parse().expect("Parse failed"))
        .collect();
}

fn process_lines<T>(func: T, end: &str)
where
    T: Fn(&str),
{
    let mut line = String::new();
    let mut _num: u32 = 0;
    while let Ok(_) = io::stdin().read_line(&mut line) {
        _num += 1;
        {
            let data = line.trim();
            if data == end {
                break;
            }
            func(data);
        }
        line.clear();
    }
}

fn main() {
    process_lines(
        |x| {
            let nums: Vec<i32> = x.split_whitespace().map(|n| n.parse().unwrap()).collect();
            let (a, b) = (nums[0], nums[1]);
            if a < b {
                println!("{} {}", a, b);
            } else {
                println!("{} {}", b, a);
            }
        },
        "0 0",
    );
}



Measured memory_bytes: 5032
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strArray = Console.ReadLine().Split(' ').ToArray();
            string N = strArray[0];
            string M = strArray[1];
            if (N == M)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//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());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

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



Measured memory_bytes: 26252
#include <cstdio>
using namespace std;
char s1[20],s2[20],s3[20];
int main() {
	scanf("%s %s %s",s1,s2,s3);
	printf("%c%c%c\n",s1[0]-'a'+'A',s2[0]-'a'+'A',s3[0]-'a'+'A');
	return 0;
}

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

int main()
{
	string s;
	int n,m;
	cin>>n>>m;
	int aa[m];
	char bb[m];
	string z;
	z+='_';
	if(n>1)
	{
		s+='1';
	}
	else s+='0';
	for(int i=1; i<n; i++)
	{
		s+='0';
		z+='_';
	}
	for(int i=0; i<m; i++)
	{
		cin>>aa[i]>>bb[i];
		s[aa[i]-1]=bb[i];
	}
	for(int i=0; i<m; i++)
	{
		//cout<<z<<endl;
		if(z[aa[i]-1]=='_' || z[aa[i]-1]==bb[i])
			z[aa[i]-1]=bb[i];
		else
		{
			cout<<"-1\n";
			return 0;
		}
	}
	int a;
	int digit=0;
	a=stoi(s);
	if(a>0)
	{
		while(a>0)
		{
			a/=10;
			digit++;
		}
	}else digit=1;
	//cout<<digit<<endl;
	if(digit==n)cout<<s<<endl;
	else cout<<"-1\n";
	//cout<<z<<endl;
	//cout<<s<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef double db;

int n,d1,x;
db s,ans;

int main()
{
	scanf("%d%d%d",&n,&d1,&x);
	s=2*n*d1+1.0*n*(2*n-1)*x;
	for(int i=n;i;i--)
	{
		ans+=s/(i*2);
		s-=s/i/i;
	}
	printf("%.10lf\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)


int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) {
        cin >> A[i];
    }
    int v;
    int j;
    rep(i,N) {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        rep(i,N) {
            if (i<N-1) {
                cout << A[i] << " ";
            } else {
                cout << A[i] << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e5;
const ll MOD=1e9+7;
const int INF=1<<30;

int N;
vector<vector<pair<int,int> > > G;
vector<int> res;

void dfs(int v,int p,int c){
  res[v]=c;
  for(auto e:G[v]){
    if(e.first==p) continue;
    if(e.second&1) dfs(e.first,v,1-c);
    else dfs(e.first,v,c);
  }
}

int main(){
  int N; cin >> N;
  G.resize(N,vector<pair<int,int> >(0));
  res.resize(N,0);
  for(int i=0;i<N-1;i++){
    int u,v,w;
    cin >> u >> v >> w;
    u--; v--;
    G[u].push_back(make_pair(v,w));
    G[v].push_back(make_pair(u,w));
  }
  dfs(0,-1,0);
  for(int i=0;i<N;i++){
    cout << res[i] << endl;
  }
}

Measured memory_bytes: 8960
<?php

list($H, $W) = explode(" ", trim(fgets(STDIN)));

$lines = [];
$lines2 = [];
foreach (range(0, $H - 1) as $i)
{
    $str = trim(fgets(STDIN));
    if(strpos($str,'#') !== false)
    {
        $lines2[] = $str;
        foreach (range(0, strlen($str) - 1) as $k)
        {
            $lines[$k][$i] = $str[$k];
        }
    }
}


$i = 0;
$excludes = [];
foreach ($lines as $line)
{
    if(!in_array("#", $line))
    {
        $excludes[] = $i;
    }
    $i++;
}


foreach ($lines2 as $line)
{
    foreach (range(0, strlen($line) - 1) as $k)
    {
        if(in_array($k, $excludes))
        {
            continue;
        }
        print $line[$k];
    }
    print PHP_EOL;
}



Measured memory_bytes: 6648
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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



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

int main() {
	string s, t;
	cin >> s >> t;
	if (s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) { cout << "YES"; }
	else { cout << "NO"; }

}


Measured memory_bytes: 256
// Problem : B - Lucas Number
// Contest : AtCoder - AtCoder Beginner Contest 079
// URL : https://atcoder.jp/contests/abc079/tasks/abc079_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
	int n;cin>>n;
	int a[n+1];
	a[0]=2;
	a[1]=1;
	for(int i=2;i<=n;i++)
	a[i]=a[i-1]+a[i-2];
	cout<<a[n];
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3584
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	int T;
	cin >> T;
	while (T--)
	{
		int h, w;
		cin >> h >> w;

		char m[32][32];
		CLEAR(m, '#');
		for (int y = 1; y <= h; ++y)
		{
			cin >> m[y] + 1;
			m[y][w + 1] = '#';
		}

		const char* dd = "v>^<";
		int x, y, dir;
		for (int yy = 1; yy <= h; ++yy)
			for (int xx = 1; xx <= w; ++xx)
				if (strchr(dd, m[yy][xx]))
				{
					x = xx, y = yy;
					dir = strchr(dd, m[yy][xx]) - dd;
					m[yy][xx] = '.';
				}

		int n;
		string s;
		cin >> n >> s;
		for (int i = 0; i < n; ++i)
		{
			char c = s[i];

			const char* dc = "DRUL";
			if (strchr(dc, c))
			{
				dir = strchr(dc, c) - dc;
				int tx = x + dx[dir], ty = y + dy[dir];
				if (m[ty][tx] == '.')
					x = tx, y = ty;
			}
			else
			{
				int tx = x + dx[dir], ty = y + dy[dir];
				while (m[ty][tx] != '#')
				{
					if (m[ty][tx] == '*')
					{
						m[ty][tx] = '.';
						break;
					}
					tx += dx[dir], ty += dy[dir];
				}
			}
		}

		m[y][x] = dd[dir];

		for (int yy = 1; yy <= h; ++yy)
		{
			for (int xx = 1; xx <= w; ++xx)
				cout << m[yy][xx];
			cout << endl;
		}
		if (T)
			cout << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>


#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define DOUT(obj,n) cout << fixed << setprecision(n) << obj << endl

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (a >= 0) {
		c -= b;
		if (c <= 0)break;
		a -= d;
	}
	if (a > 0)cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3640
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 200002;

int n;

int f[N_MAX];

multiset <int> s;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> f[i];
    sort(f + 1, f + n + 1);
    reverse(f + 1, f + n + 1);
    ll ans = 0;
    s.insert(-f[1]);
    for(int i = 2; i <= n; i++)
    {
        int t = -(*s.begin());
        s.erase(s.begin());
        ans += t;
        s.insert(-f[i]);
        s.insert(-f[i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 13804
def main():
	N = int(input())

	for a in range(0, 131, 1):
		for b in range(-131, a+1, 1):
			val = a**5 - b**5
			if(val == N):
				print(str(a) + " " + str(b))
				return

if __name__ == "__main__":
	main()

Measured memory_bytes: 9176
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

struct node {
    pi v; int d;
    node(pi v, int d):v(v),d(d){}
    bool operator<(const node &n) const { return d > n.d; }
};
struct edge { pi to; int d; edge(pi ti, int di){to = ti; d = di;} };
map<pi,vector<edge>> G;
map<pi,int> dist; // shortest distance

void dijkstra(pi s) {
    //REP(i,MAX) dist[i] = -1;
    priority_queue<node> que;
    que.push(node(s, 0));
    while(!que.empty()){
        pi v = que.top().v; int d = que.top().d;
        que.pop();
        if(dist.find(v) != dist.end() && dist[v] <= d) continue;
        dist[v] = d;
        for(auto&& j : G[v])
            que.push(node(j.to, d+j.d));
    }
}

int n,m,p,q,c;

int main(){
    I(n); I(m);
    REP(i,m){
        I(p); I(q); I(c);
        G[mp(p,0)].pb(edge(mp(p,c),1));
        G[mp(q,0)].pb(edge(mp(q,c),1));
        G[mp(p,c)].pb(edge(mp(q,c),0));
        G[mp(q,c)].pb(edge(mp(p,c),0));
        G[mp(p,c)].pb(edge(mp(p,0),0));
        G[mp(q,c)].pb(edge(mp(q,0),0));
    }
    dijkstra(mp(1,0));
    if(dist.find(mp(n,0)) != dist.end()){
        cout << dist[mp(n,0)] << endl;
    } else {
        cout << -1 << endl;
    }
}



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

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

int main()
{
  int h, w;

  while (cin >> h >> w, h + w){
  	int dx = 0, dy = 0;
    string tile[101];
    bool done[101][101], flag = false;

    REP(i, h){
      REP(j, w) done[i][j] = false;
    }
    REP(i, h) cin >> tile[i];
    while (tile[dy][dx] != '.'){
      if (done[dy][dx]){
        flag = true;
        cout << "LOOP" << endl;
        break;
      }
      done[dy][dx] = true;
      if (tile[dy][dx] == '<') dx--;
      if (tile[dy][dx] == '>') dx++;
      if (tile[dy][dx] == '^') dy--;
      if (tile[dy][dx] == 'v') dy++;
    }
    if (flag) continue;
    cout << dx << " " << dy << endl;
  }
}

Measured memory_bytes: 1240
#include <iostream>
using namespace std;
int main(){
    int A,B,C,D;
    int num;
    cin >> num;
    D=num%10;
    C=(num%100-D)/10;
    A=num/1000;
    B=num/100-A*10;
    int Anum[4]={A,B,C,D};
    int bit=8;
    int ans=A;
    for(int i=0;i<8;i++){
        ans=A;
        for(int j=0;j<3;j++){
            if((i>>j)%2==0){
                ans=ans-Anum[j+1];
            }else{
                ans=ans+Anum[j+1];
            }
        }
        if(ans==7){
            cout << Anum[0];
            for(int k=0;k<3;k++){
                if((i>>k)%2==0){
                cout << "-" <<Anum[k+1];
            }else{
                cout << "+" << Anum[k+1];
            }
            }
            cout << "=7";
            return 0;
        }
    }

    return 0;
}

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

#define ll long long 
#define mod 1e18

int main(){

    ll int A,B,C,N,M,H,W,K;
    ll int A_hold,B_hold,C_hold;
    ll int i,j,k;
    ll int min = 1000000000;
    ll int max = 0;
    ll int a,b,c,d;
    ll int count=0,count_two=0,v;
    string S[50];

    cin >> A >> B >> C >> K;

    if(K % 2 == 0 || K == 0){
        if(A-B >= mod){
            cout << "Unfair" << endl;
            return 0;
        }
        cout << A-B << endl;
    }

    else{
           if(-A+B >= mod){
            cout << "Unfair" << endl;
            return 0;
        }
        cout << -A+B << endl;
    }

    return 0;
}

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

int main(){
  long D;
  cin >> D;
  
  if (D==25) {
    cout << "Christmas" << endl;
  }
  else if (D==24) {
    cout << "Christmas Eve" << endl;
  }
  else if (D==23) {
    cout << "Christmas Eve Eve" << endl;
  }
  else if (D=-22) {
    cout << "Christmas Eve Eve Eve" << endl;
  }
   
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <map>
#include <string>
using namespace std;
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; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

struct info{
    string name;
    int score;
    int order;
};

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int N; cin >> N;
    //vector<string> sp(N);
    vector<info> infos(N);
    string tmp1;
    int tmp2;
    for (int i = 0; i < N; i++) {
        cin >> tmp1 >> tmp2;
        infos.at(i).name = tmp1;
        infos.at(i).score = tmp2;
        infos.at(i).order = i + 1;
    }
    sort(infos.begin(), infos.end(), [](const info& x, const info& y) { return x.name < y.name; });

    string target = infos.at(0).name;
    map<int, int, greater<int>> tmp;
    for (auto x : infos) {
        if (target != x.name) {
            target = x.name;
            for (auto y : tmp) {
                cout << y.second << endl;
            }
            tmp.clear();
        }
        tmp.insert(make_pair(x.score, x.order));
    }

    for (auto y : tmp) {
        cout << y.second << endl;
    }

 	return 0;
}


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

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main() {
    timesaver;
	string s, t;
	cin >> s >> t;
	int ans = INT_MAX, count = 0;
	int slen = s.length(), tlen = t.length();
	for(int i = 0; i <= slen - tlen; i++) {
		count = 0;
		for(int j = 0; j < tlen; j++) {
			if(s[i + j] != t[j])
				count++;
		}
		ans = min(count, ans);

	} 
    cout << ans;
	return 0;
} 

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
main()
{
int N,L,n;
cin >> N>>L;
string A[100];
for(int n=0;n<N;n+=1){
cin>> A[n];}
sort(A,A+N);
for(int i=0;i<N;i+=1){
cout<<A[i];
}}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r ;
	if(y>=r&&y<=H-r&&x>=r&&x<=W-r)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1160
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define bf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double d;
#define MAX 1000009
#define MIN -1
#define M 1000000007
#define INF 5e17
using namespace std;
typedef vector<ll> Vector;
typedef queue<ll > Queue;
typedef stack<ll> Stack;
typedef pair<ll,ll> Pair;
#define mp make_pair
#define pb push_back
bool desc(ll i, ll j) { return i > j; }
ll ar[MAX];
map<ll,ll> tim;
map<ll,bool> vis;
int main(){
    bf;
    ll i=0,j=0,t,k,n,l=0,a=0,b,ans=0; string s;
    cin>>n>>k;
    for(i=1;i<=n;i++) cin>>ar[i];
    sort(ar+1,ar+n+1,desc);
    for(i=1;i<=n;i++){
        vis[ar[i]]=true;
        j+=ar[i]; l++;
        if(j>=k){
            a=i;j=0,l=0;
        }
    }
    for(i=a;i>=1;i--){
        if(ar[i]<k&&j+ar[i]>=k){
            cout<<"0"; return 0;
        }
    }
     cout<<l;
    return 0;
}  

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

// input
ll N, K;
vector<ll> A;

const int bn = 41;
vector<bitset<bn>> bit;
vector<ll> p;
ll w[bn][2];
bitset<bn> bk;


void input() {
    cin >> N >> K;
    A = vector<ll>(N);
    rep(i, N) cin >> A[i];
}


ll max_sum(int n) {
    ll ret = 0;
    rep(i, n) ret += max(w[i][0], w[i][1]);
    return ret;
}


ll solve(int i) {
    if (i == -1) return 0;
    if (bk.test(i)) {
        ll x = w[i][0] + max_sum(i);
        ll y = w[i][1] + solve(i - 1);
        return max(x, y);
    } else {
        return w[i][0] + solve(i - 1);
    }
}


int main() {
    input();
    bit = vector<bitset<bn>>(N);
    rep(i, N) bit[i] = bitset<bn>(A[i]);
    p = vector<ll>(bn);
    p[0] = 1;
    rep(i, bn - 1) p[i + 1] = 2 * p[i];
    rep(i, bn) {
        ll n = 0;
        rep(j, N) if (bit[j].test(i)) n++;
        w[i][0] = p[i] * n;
        w[i][1] = p[i] * (N - n);
    }
    bk = bitset<bn>(K);
    ll ans = solve(bn - 1);
    cout << ans << endl;
}


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

int main() {
	int mt[10];
	for ( int i = 0; i < 10; i++ ) {
		cin >> mt[i];
	}

	for( int j = 0; j < 10; j++ ) {
		for ( int i = 0; i < 10-1; i++ ) {
			if( mt[ i ] < mt[ i+1 ] ) {
				int tmp = mt[ i+1 ];
				mt[ i+1 ] = mt[ i ];
				mt[ i ] = tmp;
			}
		}
	}

	for( int i = 0; i < 3; i++ ) {
		cout << mt[ i ] << endl;
	}
}

Measured memory_bytes: 0
from collections import defaultdict
N=int(input())
fac = defaultdict(int)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
            fac[i] += cnt

    if temp!=1:
        arr.append([temp, 1])
        fac[temp] += 1 

    if arr==[]:
        arr.append([n, 1])
        fac[n] += 1
    return arr

for num in range(2, N+1):
    factorization(num)

ans = 0

num_74 = set()
num_24 = set()
num_14 = set()
num_4 = set()
num_2 = set()
for key, value in fac.items():
    if value >= 74:
        num_74.add(key)
    if value >= 24:
        num_24.add(key)
    if value >= 14:
        num_14.add(key)
    if value >= 4:
        num_4.add(key)
    if value >= 2:
        num_2.add(key)
#1
ans += len(num_74)

#2
ans += len(num_24) * (len(num_2)-1)
# ans += len(num_2.difference(num_24)) * (len(num_24))*(len(num_24)-1)//2 + len(num_24) * (len(num_24)-1)*(len(num_24)-2)//2


#3
ans += len(num_14) * (len(num_4) - 1)
# ans += len(num_4.difference(num_14)) * (len(num_14))*(len(num_14)-1)//2 + len(num_14) * (len(num_14)-1) * (len(num_14) - 2) //2

#4
ans += len(num_2.difference(num_4)) * len(num_4)*(len(num_4)-1)//2 + len(num_4) * (len(num_4)-1)*(len(num_4)-2)//2


print(ans)



Measured memory_bytes: 65888
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 2020;
const int M = 1e9 + 7;
int fat[N],inv[N];

int C(int n,int k){
  if(k>n)return 0;
  return mod(fat[n]*mod(inv[k]*inv[n-k],M),M);
}

int pau(int n,int m){
  m-=n;
  if(n==0 and m==0)return 1;
  if(m<0)return 0;
  return C(n+m-1,m);
}

int32_t main(){
  fastio;
  int n,k;
  cin>>n>>k;
  int r = n-k;
  fat[0] = inv[0] = 1;
  for(int i=1;i<N;i++){
    fat[i] = (i*fat[i-1])%M;
    inv[i] = exp(fat[i],M-2,M);
  }

  for(int i=1;i<=k;i++){
    int blue = pau(i,k);
    int op1 = pau(i-1,r);//so dentro; 
    int op2 = mod(2*pau(i,r),M);
    int op3 = pau(i+1,r);
    cout<<mod(blue*mod(op1 + op2 + op3,M),M)<<endl;
  }

  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
int main (void){
  int n,k,q;
  scanf("%d",&n);
  scanf("%d",&k);
  scanf("%d",&q);
  int a[q+1];
  int sc[n+1];
  for(int i=1;i<=n;i++){
    sc[i]=k-q;
  }
  for(int i=1;i<=q;i++){
    scanf("%d",&a[i]);
    sc[a[i]]++;
  }
  for(int i=1;i<=n;i++){
    if(sc[i]<=0){printf("No\n");}
    else{printf("Yes\n");}
  }
}

Measured memory_bytes: 1408
#include <iostream>
#include <limits>
#include <iomanip> 
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 


struct V {
    double x;
    double y;
    explicit V(double init_x = 0, double init_y = 0) : x(init_x), y(init_y) {}
    V(const V& rhs) : x(rhs.x), y(rhs.y) {}
    V& operator=(const V& rhs) {
        if (this != &rhs) {
            x = rhs.x;
            y = rhs.y;        
        }
        return *this;
    }
    double norm() const { return sqrt(x*x+y*y); }
};

inline double innerProduct(const V& lhs, const V& rhs) { return (lhs.x * rhs.x + lhs.y * rhs.y); }
inline V operator+(const V& lhs, const V& rhs) { return V(lhs.x + rhs.x, lhs.y + rhs.y); }


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

    vector<V> e(N);
    for (int i = 0; i < N; ++i) {
        cin >> e[i].x >> e[i].y;
    }

    double ans = 0;
    const double EPS = 0.00000000000000000000001;
    const double cos_EPS = cos(EPS);
    const double sin_EPS = sin(EPS);
    const double cos_90 = 0;
    const double sin_90 = 1.0;

    for (const V& v: e) {
        vector<V> dir(6);
        dir[0].x =  cos_EPS * v.x - sin_EPS * v.y; 
        dir[0].y =  sin_EPS * v.x + cos_EPS * v.y; 
        dir[1].x =  cos_90 * dir[0].x - sin_90 * dir[0].y; 
        dir[1].y =  sin_90 * dir[0].x + cos_90 * dir[0].y; 
        dir[2].x =  cos_90 * dir[0].x + sin_90 * dir[0].y; 
        dir[2].y =  -sin_90 * dir[0].x + cos_90 * dir[0].y; 
        dir[3].x =  cos_EPS * v.x + sin_EPS * v.y; 
        dir[3].y = -sin_EPS * v.x + cos_EPS * v.y; 
        dir[4].x =  cos_90 * dir[0].x - sin_90 * dir[3].y; 
        dir[4].y =  sin_90 * dir[0].x + cos_90 * dir[3].y; 
        dir[5].x =  cos_90 * dir[0].x + sin_90 * dir[3].y; 
        dir[5].y =  -sin_90 * dir[0].x + cos_90 * dir[3].y; 
        for (const V& d: dir) {
            V vSum;
            for (const V& t: e) {
                if (0 <= innerProduct(t, d)) {
                    vSum = vSum + t;
                }
            }
            ans = max(ans, vSum.norm());
        }
    }

    printf("%.30f\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	cout<<a[0][0]<<a[1][1]<<a[2][2]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<math.h>
#define ll long long
#define ld long double
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
 int main()
{
  Summon_Tourist
  //freopen("input.txt" , "r" , stdin ) ;
  vector<ll> a(5);
  for( ll i = 0 ; i<5 ; i++ ) cin>>a[i];
  for( ll i = 0 ; i<5 ; i++ ){
        if( a[i]==0 ) { cout<<i+1;break; }
  }
  return 0;

}


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

int main(){
    long long int a, b, ans = 0;
    cin >> a >> b;
    if((a-1)%4 == 0){
        ans ^= a-1;
    }else if((a-1)%4 == 1){
        ans ^= 1;
    }else if((a-1)%4 == 2){
        ans ^= (a-1)^1;
    }
    if((b)%4 == 0){
        ans ^= b;
    }else if((b)%4 == 1){
        ans ^= 1;
    }else if((b)%4 == 2){
        ans ^= (b)^1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	char s[10000],c;
	int n,i;
	scanf("%d%s",&n,s);
	for(i=0;s[i]!='\0';i++){
		if(s[i]+n<='Z'){
			c=s[i]+n;
		}
		else{
			c=s[i]-'Z'+'A'+n-1;
		}
		printf("%c",c);
	}
	return 0;
}

Measured memory_bytes: 1672
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define N 100001
using namespace std;
ll fact(ll n)
{
ll    res=1;
    for(int i = 1; i <= n;i++){
    res = res * i ;
}
return res;
}



int main()
{   IOS;
    ll a;
    cin >> a;
    vector<string> L;
    for(int i=0;i<a;i++)
    {
        string ch;
        cin >> ch ;
        sort(ch.begin(),ch.end());
        L.push_back(ch);
    }
    sort(L.begin(),L.end());
    /*for(int i=0;i<a;i++)
        cout << L[i];*/
    ll str=1;
    vector <ll> L2;
    for(int i=0;i<a-1;i++)
    {
        if (L[i]==L[i+1])
            str++;
        else
           {
                L2.push_back(str);
                str=1;
           }

    }
    if(str!=1) L2.push_back(str);
    ll res=0;
    for(int i=0;i<L2.size();i++)
        {
            if(L2[i]!=1)
                res+=(L2[i]*(L2[i]-1))/2;
        }


    cout << res;




    cout.precision(30);
    return 0;
}


Measured memory_bytes: 7284
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=55;
typedef long long ll;
ll n,d[MAXN];
int main(){
	scanf("%lld",&n);
	ll t1=0,t2=0;
	for (int i=1;i<=n;i++){
		scanf("%lld",&d[i]);
		t1+=d[i]; t2+=d[i]*d[i];
	}
	printf("%lld\n",(t1*t1-t2)/2);
	return 0;
}


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

l=[1]
l_9=[pow(9,i) for i in range(1,7)]
l_6=[pow(6,i) for i in range(1,8)]
l+=l_9
l+=l_6
l.sort(reverse=True)
dp=[10**9 for i in range(n+1)]

dp[0]=0

for i in range(1,n+1):
    for j in l:
        if i-j>=0:
            dp[i]=min(dp[i],dp[i-j]+1)
print(dp[n])

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll ans=0;
	ll ans2=INF;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		ans+=x;
		if(x%10!=0){
			ans2=min(ans2,x);
		}
	}
	cout << (ans%10!=0? ans:max(ll(0),ans-ans2));
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define clr(a,b) memset(a,b,sizeof(a))
using namespace std;

typedef long long ll;

int n, a[55];
int main(){
    cin >> n;
    int res = 0;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++) {
            res += a[i] * a[j];
        }
    cout << res << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
            using namespace std;
            
            int main(){
            
                int N; 
                cin >> N ;
                vector<int> W(N); 
                int answer=100000; 
                
                for(int i=0; i< N; i++){
                    cin>> W.at(i); 
                }
                
                for(int T=1; T<N; T++){
                    int S_1=0;
                    int S_2=0; 
                    for(int i=0; i<N; i++){
                        if(i>T) S_1+=W.at(i); 
                        if(i<=T) S_2+=W.at(i); 
                    }
                    //cout<< T <<" "<<S_1<<" "<<S_2<<endl; 
                    answer = min( abs(S_1-S_2), answer ); 
                    
                }
   
     
                cout<< answer ;   
            }

Measured memory_bytes: 256
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	
    int n,m;
    cin>>n>>m;
    vi v[n];
    int ht[n];
    for(int i=0;i<n;i++)cin>>ht[i];

    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        x--,y--;
        v[x].pb(y);
        v[y].pb(x);
    }

    int cnt=0;
    for(int i=0;i<n;i++)
    {
        bool flag=true;
        for(auto it:v[i])
        {
            if(ht[i]<=ht[it])
            flag=false;
        }
        if(flag)
        cnt++;
    }
    cout<<cnt;
    

return 0;
}

Measured memory_bytes: 10240
import java.io.*
import java.util.*

fun solve(N: Int, K: Int, a: IntArray) {
    // dp[i] = i残っているときに先行が勝つときtrue
    // dp[i] = (!dp[i-a[j]]).any()
    a.sort()
    val dp = BooleanArray(K+1){ false }
    a.forEach{ dp[it] = true }
    for (i in 1..K){
        // val ret = a.filter{ it <= i }.map{ !dp[i-it] }
        // println(i)
        // println(ret)
        dp[i] = a.filter{ it <= i }.map{ !dp[i-it] }.any{ it }
    }
    // println(dp.toList())
    if(dp[K]) println("First")
    else println("Second")
    return
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val K = sc.next().toInt()
    val a = IntArray(N.toInt())
    for (i in 0 until N.toInt()) {
        a[i] = sc.next().toInt()
    }
    solve(N, K, a)
}


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

int main() {
	int n;
	while(true) {
		cin >> n;
		if (n == 0) {
			break;
		}

		int count = 0;
		for (int i = 2; i <= n*2 / i; i += 2) {
			if(n % i != 0 && n*2 % i == 0) {
				int centerMinusHalf = n / i;

				if(centerMinusHalf + 1 - i / 2 > 0) {
					count++;
				}
			}
		}
		for (int i = 3; i <= n*2 / i; i += 2) {
			if(n % i == 0) {
				int center = n / i;

				if(center - i / 2 > 0) {
					count++;
				}
			}
		}

		cout << count << endl;
	}
	return 0;
}

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

typedef long long ll;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;

#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define MOD 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  ll n, m;
  cin >> n >> m;
  map<int, int> mp;
  map<int, bool> flag;
  int suma = 0, sumb = 0;
  rep(i, m) {
    int a;
    string s;
    cin >> a >> s;
    
    if (s == "AC") {
      if (!flag[a]) suma += 1;
      flag[a] = true;
    } else {
      if (!flag[a]) {
        mp[a] += 1;
        sumb += 1;
      }
    }
  }

  for (int i = 1; i <= n; ++i) {
    if (!flag[i]) {
      sumb -= mp[i];
    }
  }

  cout << suma << " " << sumb << endl;
}


Measured memory_bytes: 9600