akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

void solve() {
  string s; cin >> s;
  vi cnt(2, 0);
  rep(i,s.size()) ++cnt[s[i]-'0'];
  cout << 2 * min(cnt[0], cnt[1]) << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;

namespace ConsoleApp_ITP1_3_D
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> inputList = new List<string>();

            for (int i = 1; i <= 3000; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                var x = Int32.Parse(input[0]);
                var y = Int32.Parse(input[1]);

                if (x == 0 && y == 0)
                {
                    break;
                }
                else
                {
                    if (y < x)
                    {
                        var j = x;
                        x = y;
                        y = j;
                    }
                    var output = String.Concat(x, ' ', y);
                    inputList.Add(output);
                }
            }

            for (int i = 0; i < inputList.Count; i++)
            {
                Console.WriteLine(inputList[i]);
            }
        }
    }
}


Measured memory_bytes: 9436
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int n;
	int i,j,u;
	int ans=0;

	scanf("%d",&n);

	int L[n];
	for(i=0;i<n;i++)
	  scanf("%d",&L[i]);

	for(i=0;i<n-2;i++)
	  for(j=i+1;j<n-1;j++)
	   for(u=j+1;u<n;u++)
          if(L[i]>abs(L[j]-L[u])&&L[i]<L[j]+L[u]&&L[i]!=L[j]&&L[j]!=L[u]&&L[i]!=L[u]){
		    ans+=1;
		  }
	
	printf("%d\n",ans);
	   

	return 0;
}

Measured memory_bytes: 1732
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()

c=m-n*2

if c>=0:
    print(n+c//4)
else:
    print(min(m//2,n))

Measured memory_bytes: 63340
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string w;
  cin >> w;
  transform(w.begin(), w.end(), w.begin(), ::tolower);
  string t;
  cin >> t;
  int cnt = 0;
  while (t != "END_OF_TEXT") {
    transform(t.begin(), t.end(), t.begin(), ::tolower);
    if (t == w) {
      cnt++;
    }
    cin >> t;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
 
main()
{
  int n;
  int c[501];
  int s[501];
  int f[501];
  int t[501];
  
  cin >> n;
  for(int i=0;i<n-1;i++)
    cin >> c[i] >> s[i] >> f[i];
 
  for(int i=0;i<n;i++){
    int ans=0;
    for(int j=i;j<n-1;j++){
      if(ans<s[j])
        ans=s[j];
      else if(ans%f[j]!=0){
        int k;
        for(k=1;f[j]*k<ans;k++){int a;}
        ans+=(f[j]*k)-ans;
      }
      ans+=c[j];
    }
    cout << ans << endl;
  }
  
  return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define Fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
 
int main() {
    Fast
    
    ll n,w; cin>>n>>w;
    ll wgh[n], val[n];
    for(ll i=0; i<n; i++) {cin>>wgh[i]; cin>>val[i];}
 
    ll dp[n][w+1];
    for(ll i=0; i<n; i++) dp[i][0]=0;
    for(ll i=0; i<=w; i++) {
        if(i<wgh[0]) dp[0][i]=0;
        else dp[0][i]=val[0];
    }
 
    for(ll i=1; i<n; i++) {
        for(ll j=1; j<=w; j++) {
            if(wgh[i]>j) dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(dp[i-1][j], val[i]+dp[i-1][j-wgh[i]]);
        }
    }
  
    cout<<dp[n-1][w];
}

Measured memory_bytes: 78336
function Main(input){
var all = input.split(" ");
var A = parseInt(all[0],10);
var B = parseInt(all[1],10);

var p = A + B;
var m = A - B;
var t = A * B;


if(p >= m && p >= t){
    console.log(p);
}else if(m >= p && m >= t){
    console.log(m);
}else{
    console.log(t);
}
}





Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());
  
  int N,M;
  cin>>N>>M;
  int L,R;
  cin>>L>>R;
  for(int i=1;i<M;i++){
    int Lt,Rt;
    cin>>Lt>>Rt;
    L=max(L,Lt);
    R=min(R,Rt);
  }
  if(R-L+1>0){
    cout<<R-L+1<<endl;
  }else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		for(int i=0; i<n; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			
			a = a*a;
			b = b*b;
			c = c*c;
			
			if(a == b + c || b == a + c || c == a + b )
				System.out.println("YES");
			else
				System.out.println("NO");			
			
		}
		
	}

}

Measured memory_bytes: 23400
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

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

    vector< vector<ll> > v(n);
    for(int i = 0; i < n; i++){
        v[i].resize(26);
        for(int j = 0; j < s[i].size(); j++ ){
            char c =  s[i][j] - 'a';
            v[i][c] ++;
        }
    }


    for(int i = 0; i < 26; i++){
        ll minCnt = 100;
        for(int j = 0; j < n; j++){
            minCnt = min( v[j][i], minCnt  );
        }
        for(int j = 0; j < minCnt; j++){
            cout << (char)(i + 'a') ;
        }
    }
    cout << endl;

}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  !al <- replicateM h $ map (== '#') <$> getLine
  let
    red = flip map [1..h] $ \i -> flip map [1..w] $ \j -> odd i && j /= w || j == 1
    blue = map (map not) red
    po = zipWith (zipWith (||)) al
    printColor = putStrLn . unlines . map (map (\b -> if b then '#' else '.'))
  printColor (po red)
  printColor (po blue)


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

int main(void){
  int n;
  set<set<int> > ss;
  
  cin >> n;
  for (int i=0; i<n; i++){
    set<int> s;
    for (int j=0; j<3; j++){
      int t;
      cin >> t; s.insert(t);
    }
    ss.insert(s);
  }
  cout << n-ss.size() << endl;
  return 0;
}


Measured memory_bytes: 3332
#include <iostream>

using namespace std;

int main()
{
	long long n, k;
	cin >> n >> k;

	long long ans = (n / k) * (n / k) * (n / k);
	if (k % 2 == 0) {
		long long t = n / (k / 2) - n / k;
		ans += t * t * t;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
from math import ceil

def main():
    n = int(input())
    a = list(map(int,input().split()))
    d = {}
    for x in a:
        d[x] = d.get(x,0)+1
    ans = 0
    for x in d.values():
        ans+=(x*(x-1))//2
    for x in a:
        if d[x] == 1:
            print(ans)
            continue
        old = (d[x]*(d[x]-1))//2
        d[x]-=1
        new = (d[x]*(d[x]-1))//2
        d[x]+=1
        print(ans-old+new)







# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 27016
import itertools

n=int(input())
p=input().split()
q=input().split()

z=list(range(1,n+1))
z_str=[str(m) for m in z]
i=1

for v in list(itertools.permutations(z_str)):
  li=list(v)
  if p==li:
    a=int(i)
  if q==li:
    b=int(i)
  i=i+1

print(abs(a-b))

Measured memory_bytes: 8052
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <map>

using namespace std;

#define FOR(i, a, b) for(i=a; i<b; ++i)
#define EFOR(i, a, b) for(i=a; i>b; --i)

#define MAXN 100001

void solver(int *nums, int numsSize, int m) {
	int i,j;
	int r;
	long long int sum = 0;
	long long int ret = 0;
	//int *dp = (int *)calloc(m, sizeof(int));

	//if (nums[0]%m == 0) {
	//	ret = 1;
	//	dp[1] = 1;
	//}
	//printf("sum %lld dp[%d]=%lld\n", sum, 1, dp[1]);

	//FOR(i, 2, numsSize+1) {
	//	sum = nums[i-1];
	//	//printf("sum %lld dp[%d]=%d\n", sum, i, dp[i]);
	//	EFOR(j, i-1, 0) {
	//		if (sum%m==0) {
	//			dp[i] = dp[j] + 1;
	//			//printf("===j %d sum %lld dp[%d]=%lld\n", j, sum, i, dp[i]);
	//			break;
	//		}

	//		sum += nums[j-1];
	//	}

	//	if (sum%m == 0 && j==0)
	//		dp[i]++;
	//	ret += dp[i];
	//	//printf("sum %lld dp[%d]=%lld\n", sum, i, dp[i]);
	//}
	
	map<int, int>dp;
	dp[0] = 1;

	FOR(i, 0, numsSize) {
		sum += nums[i];
		r = sum%m;
		ret += dp[r];
		dp[r]++;
	}

	printf("%lld\n", ret);
}

int main() {
	int i,n,m;
	int a[MAXN] = {0};

	scanf("%d %d", &n, &m);

	FOR(i, 0, n) {
		scanf("%d", &a[i]);
	}
	solver(a, n, m);
	return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e2 + 5;
ll a,b;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>b;
    cout<<max(0LL, a - 2 * b);
    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;cin>>n;
  vector<ll>t(n);
  vector<ll>a(n);
  for(int i=0;i<n;i++)
    cin>>t[i];
  for(int i=0;i<n;i++)
    cin>>a[i];
  //reverse(a.begin(),a.end());
  bool flag[n]={};
  flag[0]=true;
  flag[n-1]=true;
  for(int i=1;i<n;i++){
    if(t[i]!=t[i-1])flag[i]=true;
  }
  for(int i=n-2;i>=0;i--){
    if(a[i]!=a[i+1])flag[i]=true;
  }
  const ll MOD=1000000007;
  ll ans=1;
  ll nnn=0;
  for(int i=0;i<n;i++){
    int cnt=0;
    while((i!=n)&&(!flag[i])){
      cnt++;
      i++;
    }
    if(cnt>0){
      ll ans2=1;
      ll num=min(a[i-1],t[i-1]);
      for(int j=0;j<cnt;j++){
	ans=(ans*num)%MOD;
      }
    }
  }
  bool flag2=true;
  for(int i=0;i<n;i++){
    if(a[i]==t[n-1]&&t[i]==t[n-1]){
      flag2=false;
      break;
    }
  }
  if((t[n-1]!=a[0])||flag2){
    cout<<0<<endl;
  }else if(n==1&&a[0]==t[0])
    cout<<1<<endl;
  else
    cout<<ans<<endl;
  return 0;
}


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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	string s; cin >> s;

	int mini = n;
	int cntB = 0;
	int cntW = 0;
	REP(i, n) {
		if (s[i] == '.')
			cntW++;
	}
	REP(i, n) {
		mini = min(mini, cntB + cntW);
		if (s[i] == '#')
			cntB++;
		else
			cntW--;
	}
	mini = min(mini, cntB + cntW);
	cout << mini << '\n';
	return 0;
}

Measured memory_bytes: 3732
#include <cstdio>
using namespace std;

struct Node {
	Node *parent;
	Node *left;
	Node *right;
	int key;
};

Node *NIL = NULL;
Node *root = NIL;

void preorder(Node *v) {
	if (v == NIL) return;
	printf(" %d", v->key);
	preorder(v->left);
	preorder(v->right);
}

void inorder(Node* v) {
	if (v == NIL) return;
	inorder(v->left);
	printf(" %d", v->key);
	inorder(v->right);
}

void postorder(Node* v) {
	if (v == NIL) return;
	postorder(v->left);
	postorder(v->right);
	printf(" %d", v->key);
}

void insert(Node* &T, Node *z) {
	Node *y = NIL;
	Node *x = T;
	while (x != NIL) {
		y = x;
		if (z->key < x->key)
			x = x->left;
		else
			x = x->right;
	}
	z->parent = y;

	if (y == NIL)
		T = z;
	else if (z->key < y->key)
		y->left = z;
	else
		y->right = z;
}

bool find(Node* T, int key) {
	Node *x = T;
	if (x == NIL) return false;
	if (x->key == key)
		return true;
	else if (key < x->key)
		return find(x->left, key);
	else
		return find(x->right, key);
}

Node* findNext(Node *z) {
	if (z == NIL) return NIL;
	if (z->right != NIL) {
		Node *x = z->right;
		while (x->left != NIL) {
			x = x->left;
		}
		return x;
	}

	Node *y = z->parent;
	while (y != NIL && y->right == z) {
		z = y;
		y = z->parent;
	}
	return y;
}

void del(Node* z, int key) {
	if (z == NIL) return;
	if (z->key == key) {
		if (z->left == NIL && z->right == NIL) {
			Node *w = z->parent;
			if (w != NIL && w->left == z) {
				w->left = NIL;
			} else if (w != NIL && w->right == z) {
				w->right = NIL;
			}
			if (z->parent == NIL) root = NIL;
			delete z;
		} else if (z->right == NIL) {
			Node *w = z->parent;
			Node *x = z;
			Node *y = z->left;
			z = y;
			if (w != NIL) {
				if (w->left == x) w->left = z;
				else              w->right = z;
			}
			if (x->parent == NIL) root = NIL;
			delete x;
		} else if (z->left == NIL) {
			Node *w = z->parent;
			Node *x = z;
			Node *y = z->right;
			z = y;
			z->parent = w;
			if (w != NIL) {
				if (w->right == x) w->right = z;
				else               w->left = z; 
			}
			if (x->parent == NIL) root = NIL;
			delete x;
		} else {
			Node* x = findNext(z);
			z->key = x->key;
			del(x, x->key);
		}
	} else if (key < z->key) {
		del(z->left, key);
	} else {
		del(z->right, key);
	}
}

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

	for (int i = 0; i < n; ++i) {
		char cmd[20];
		int v;
		scanf("%s", cmd);
		if (cmd[0] == 'i') {
			scanf("%d", &v);
			Node *p = new Node;
			p->key = v;
			p->left = NIL;
			p->right = NIL;
			insert(root, p);
		} else if (cmd[0] == 'f') {
			scanf("%d", &v);
			printf("%s\n", find(root, v) ? "yes" : "no");
		} else if (cmd[0] == 'p') {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		} else if (cmd[0] == 'd') {
			scanf("%d", &v);
			del(root, v);
		}
	}

	return 0;
}

Measured memory_bytes: 19796
#include<stdio.h>
int main(){
  
  char a;
  
  scanf("%s",&a);
  
  if('A'== a){
    printf("T");
  }
  
  if('C' == a){
  	printf("G");
  }
  if('G' == a){
  	printf("C");
  }
  if('T' == a){
  	printf("A");
  }
 
	return 0;
  
}



Measured memory_bytes: 128
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, k int
	var a []int
	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		var i int
		fmt.Scan(&i)
		a = append(a, i)
	}

	fmt.Println(math.Ceil(float64(n-1) / float64(k-1)))
}


Measured memory_bytes: 5504
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int X = sc.nextInt();
  int A = sc.nextInt();
  int B = sc.nextInt();
  if(B-A <= 0)System.out.println("delicious");
  else if(B-A > X)System.out.println("dangerous");
  else System.out.println("safe");
}
}

Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <queue>
#define int long long
using namespace std;
priority_queue<int> pque;
signed main(){
    string command;
    int n;
    while(cin >> command){
        if(command == "insert"){
            cin >> n;
            pque.push(n);
        }else if(command == "extract"){
            cout << pque.top() << endl; pque.pop();
        }else{
            break;
        }
    }
}


Measured memory_bytes: 11256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define INF 100000000
#define uint unsigned int
using namespace std;

/*]
no-count transpotationを考える
Trans1 Xtimes then time+= X;
Trans2 Y times
if*/
int main() {
	ll N;
	cin >> N;
	vector<ll> abcde(5);

	rep(i, 5) {
		cin >> abcde.at(i);
	}
	vector<ll> worktimes(5);
	vector<ll> kaisu(5);
	ll ans = 0;
	for (int i = 0; i < 5; i++) {
		if (i == 0) {
			worktimes.at(i) = N / abcde.at(i) + (N % abcde.at(i) ? 1 : 0);
		}
		else {
			if (abcde.at(i) > abcde.at(i - 1)) {
				worktimes.at(i) = worktimes.at(i - 1);
			}
			else {
				worktimes.at(i) = max (N / abcde.at(i) + (N % abcde.at(i) ? 1 : 0) , worktimes.at(i-1));
			}
		}
	}
	
	for (int i = 0; i < 5; i++) {
		worktimes.at(i) += i;
	}
	
	cout << worktimes.at(4) << endl;
}


Measured memory_bytes: 256
<?php
	$n = trim(fgets(STDIN));

	$h = intval($n / 3600);
	$n = ($h) ? ($n - 3600 * $h) : $n;

	$m =  intval($n / 60);
	$n = ($m) ? ($n - 60 * $m) : $n;

	$s = $n % 60;
	printf("%d:%d:%d\n", $h, $m, $n);

Measured memory_bytes: 6540
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) {

            var input = int.Parse(Console.ReadLine());

            for(int a = 1; a <= 9; a++) {

                for(int b = 1; b <= 9; b++) {

                    if(a * b == input) {

                        Console.WriteLine("Yes");
                        return;

                    }

                }

            }

            Console.WriteLine("No");

        }

        

    }
}

Measured memory_bytes: 27476
#include <bits/stdc++.h>
using namespace std;
int setTime(int n) {
  if (n % 10 == 0) return n;
  else {
    int a = n/10;
    return (a+1)*10;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> pre(0);
  vector<pair<int,int> > vec(0);
  int a, tim = 0;
  for (int i = 0; i < 5; i++) {
    cin>>a;
    if (a % 10 == 0) tim += a;
    else vec.push_back(make_pair(a%10, a));
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int n = vec.size();
  n = max(0, n-1);
  for (int i = 0; i < n; i++) {
    tim += setTime(vec.at(i).second);
  }
  if (vec.size() != 0)tim += vec.at(n).second;
  cout << tim << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

bool judge(long long K, long long N){
    if(N%K==0) return judge(K, N/K);
    else return N%K==1;
}

int main(){
    long long N;
    cin >> N;
    auto div0 = divisor(N);
    auto div1 = divisor(N-1);
    long long ans = 0;
    for(auto x : div0){
        if(x == 1) continue;
        ans += judge(x, N);
    }
    ans += div1.size() - 1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID
#include<string>
#include<bits/stdc++.h>


#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define print(v) for(auto it=(v).begin();it!=(v).end();it++) {cout<<*it<<" ";}
#define ll long long
#define w(t) ll t;cin>>t;while(t--)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
using namespace std;

int main()
{
    int n;
    cin>>n;
    int a=(n+1)/2;
    float ans=a/(float)n;
    cout<<ans<<"\n";
    return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 256
while True:
    nums = input().split()
    a = int(nums[0])
    b = int(nums[2])
    op = nums[1]
    
    if op == '?':
        break
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)

Measured memory_bytes: 7628
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#define all(c) (c).begin(),(c).end()
#define f first
#define s second

using namespace std;

typedef long long ll;

struct point{ll x,y,z;};

typedef pair<point,point> P;

int main(void){
  ll n,k,x1,x2,y1,y2,z1,z2;
  vector<ll>x,y,z;

  cin >> n >> k;
  vector<P> p(n);

  for(int i=0;i<n;i++){
    cin >> p[i].f.x >> p[i].f.y >> p[i].f.z;
    cin >> p[i].s.x >> p[i].s.y >> p[i].s.z;

    x.push_back(p[i].f.x);
    x.push_back(p[i].s.x);
    y.push_back(p[i].f.y);
    y.push_back(p[i].s.y);
    z.push_back(p[i].f.z);
    z.push_back(p[i].s.z);
  }
  
  sort(all(x));
  sort(all(y));
  sort(all(z));

  map<ll,int>X,Y,Z;
  
  for(int i=0;i<x.size();i++)X[x[i]]=i;
  for(int i=0;i<y.size();i++)Y[y[i]]=i;
  for(int i=0;i<z.size();i++)Z[z[i]]=i;
  
  int grid[101][101][101];
  for(int i=0;i<101;i++)
    for(int j=0;j<101;j++)
      for(int l=0;l<101;l++)
	grid[i][j][l]=0;

  for(int i=0;i<n;i++){
    for(int xi=X[p[i].f.x];xi<X[p[i].s.x];xi++){
      for(int yi=Y[p[i].f.y];yi<Y[p[i].s.y];yi++){
	for(int zi=Z[p[i].f.z];zi<Z[p[i].s.z];zi++){
	  grid[xi][yi][zi]++;
	}
      }
    }
  }
  
  ll ans=0;
  for(int i=0;i<x.size()-1;i++){
    for(int j=0;j<y.size()-1;j++){
      for(int l=0;l<z.size()-1;l++){
	if(grid[i][j][l]>=k){
	  ans+=(x[i+1]-x[i])*(y[j+1]-y[j])*(z[l+1]-z[l]);
	}
      }
    }
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5264
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  string X;
  cin>>X;
  int a=0;
  int s=0;
  for(auto& ch : X) {
    if(ch=='S') {
      s++;
    } else {
      if(s>0) {
        s--;
        a++;
      }
    }
  }
  cout << X.size()-2*a<<endl;
  return 0;
}


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

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

  vector<int> x;
  vector<int> y;

  for(int i = 0; i < n; i++){
    int pb;
    cin >> pb;
    x.push_back(pb);
    y.push_back(pb);
  }
  sort(y.begin(), y.end());

  for(int i = 0; i < n; i++){
    if(x.at(i) < y.at(n/2)){
      cout << y.at(n/2) << endl;
    }else if(x.at(i) >= y.at(n/2)){
      cout << y.at((n/2)-1) << endl;
    }
  }
}


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

int main() {
 	string s;
  	cin >> s;
  	if(s == "ARC") {
     	cout << "ABC" << endl; 
    }
  	else {
     	cout << "ARC" << endl; 
    }
  	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INf=1001001001;

int main(){
  int N,M;cin>>N>>M;
  ans(N==M);
}

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

int n;
int h[100005];
long long dp[100005];

int main()
{
  	cin >> n;
  	for (int i = 1; i <= n; ++ i) {
      	cin >> h[i];
    }
  	
  	dp[1] = 0;
  	dp[2] = abs(h[2] - h[1]);
  	for (int i = 3; i <= n; ++ i) {
      	dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
  
  	cout << dp[n];
}

Measured memory_bytes: 4720
#include <bits/stdc++.h>
using namespace std;
int n;
string s,t,c;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>n>>s>>t;
for(int i=0;i<n;i++){
	 c.push_back(s[i]);
	 c.push_back(t[i]);
}
cout<<c;
return 0;
}


Measured memory_bytes: 256
c(int*a,int*b){return*a-*b;}
N,L[2000],i,j,k,s;
main(){
	scanf("%d",&N);
	for(;k<N;)scanf("%d",L+k++);
	qsort(L,N,4,c);
	for(;i<N;i++)for(j=i+1;j<N;j++)for(k=j+1;k<N;k++)s+=L[k]<L[i]+L[j];
	printf("%d",s);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  ll n, k;
  cin >> n >> k;
  ll a[1010];
  rep(i, n) cin >> a[i];
  ll csum[1010];
  csum[0] = 0;
  rep(i, n) csum[i + 1] = csum[i] + a[i];
  vector<ll> v;
  rep(l, n + 1) REP(r, l + 1, n + 1)
  {
    v.push_back(csum[r] - csum[l]);
  }
  bool usable[1010 * 1010];
  rep(i, 1010 * 1010) usable[i] = true;
  ll t = 1LL << 50;
  ll ans = 0;
  while (t != 0)
  {
    ll cnt = 0;
    vector<ll> unused;
    rep(i, v.size())
    {
      if (!usable[i])
        continue;
      if ((v[i] % (t * 2)) / t == 1)
      {
        cnt++;
      }
      else
      {
        unused.push_back(i);
      }
    }

    if (cnt >= k)
    {
      ans += t;
      for (auto un : unused)
        usable[un] = false;
    }
    t >>= 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 13420
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>

//void Aoj_learning1();
//void Aoj_learning2();
//void Aoj_learning3();
//void Aoj_learning4();
//void Aoj_learning5();
//void Aoj_learning6();
void Aoj_learning8();
void Aoj_learning8sub(int, int, int*, int*);

int main()
{
	Aoj_learning8();

	return 0;
}

void Aoj_learning8()
{
	std::string sInput;
	int intInputNum = 0;
	std::istringstream ss;	// 汎用文字列ストリーム

	// 入力個数の取得
	std::cin >> sInput;
	ss = std::istringstream(sInput);
	ss >> intInputNum;
	if (intInputNum > 1000000 || 1 > intInputNum)
	{
		exit(0);
	}

	// 数値取得
	std::string* sInputNum;
	sInputNum = new std::string[1000000];
	int* iInputNum;
	iInputNum = new int[1000000];
	for (int count = 0; count < intInputNum; count++)
	{
		std::cin >> sInputNum[count];
		ss = std::istringstream(sInputNum[count]);
		ss >> iInputNum[count];			// Stringで渡すのが面倒なためint配列に
	}

	// シェルソート
	int m = 1;
	int G[1000];
	G[0] = 1;
	int cnt = 0;

	// 間隔を決める
	int temp = 3;
	for (int i = 1;; i++)
	{
		//G[i] = i * 3 + 1;
		G[i] = i + temp;
		if (G[i] < intInputNum)
		{
			m++;
		}
		else
		{
			break;
		}
		temp = temp * 3;
	}

	for (int i = m-1; i >= 0; i--)
	{
		Aoj_learning8sub(intInputNum, G[i], iInputNum, &cnt);
	}

	// 各パラメータを表示
	std::cout << m << std::endl;
	for (int i = m-1; i >= 0; i--)
	{
		std::cout << G[i];
		if (i == 0)
		{
			std::cout << std::endl;
		}
		else
		{
			std::cout << " ";
		}
	}
	std::cout << cnt << std::endl;

	// 整列した数列を表示
	for (int k = 0; k < intInputNum; k++)
	{
		//std::cout << sInputNum[k] << std::endl;
		std::cout << iInputNum[k] << std::endl;
	}
}

// 挿入ソート
void Aoj_learning8sub(int input, int G, int *A, int* cnt)
{
	int v1;
	int j = 0;
	// 数列をソートする
	for (int i = G; i < input; i++)
	{
		v1 = A[i];
		j = i - G;
		while(j >= 0 && A[j] > v1)
		{
			A[j + G] = A[j];
			j = j - G;
			*cnt = *cnt + 1;
		}
		A[j + G] = v1;
	}
}


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

struct StList
{
  int  m_nKey;
  StList *m_poPrev;
  StList *m_poNext;
  
  StList() :
    m_nKey(0), m_poPrev(nullptr), m_poNext(nullptr)
  { }

  StList(int nNum, StList &roHead) :
    m_nKey(nNum), m_poPrev(&roHead), m_poNext(roHead.m_poNext)
  { }

  ~StList() { }
};

void fnLinkedListSet(StList &roHead, StList &roTrail)
{
  char acCmd[80];
  int nMaxCmd, nNum;

  cin >> nMaxCmd;
  for (int i = 0; i < nMaxCmd; i++)
  {
    cin >> acCmd;
    if (acCmd[0] == 'i')
    {
      cin >> nNum;
      StList *poList = new StList(nNum, roHead);
      roHead.m_poNext->m_poPrev = poList;
      roHead.m_poNext = poList;
    }
    else if (acCmd[6] == 'F')
    {
      StList *poList = roHead.m_poNext;
      if (poList != &roTrail)
      {
        poList->m_poNext->m_poPrev = poList->m_poPrev;
        roHead.m_poNext          = poList->m_poNext;
        delete poList;
      }
    }
    else if (acCmd[6] == 'L')
    {
      StList *poList = roTrail.m_poPrev;
      if (poList != &roHead)
      {
        roTrail.m_poPrev         = poList->m_poPrev;
        poList->m_poPrev->m_poNext = poList->m_poNext;
        delete poList;
      }
    }
    else if (acCmd[0] == 'd')
    {
      cin >> nNum;
      StList *poList = roHead.m_poNext;
      while (poList != &roTrail)
      {
        if (poList->m_nKey == nNum)
        {
          poList->m_poNext->m_poPrev = poList->m_poPrev;     
          poList->m_poPrev->m_poNext = poList->m_poNext;
          delete poList;
          break;
        }
        poList = poList->m_poNext;
      }
    }
  }
}

void fnLinkedListGet(StList &roHead, StList &roTrail)
{
  StList *poList = roHead.m_poNext;
  while (poList != &roTrail)
  {
    if (poList != roHead.m_poNext) cout << " ";
    cout << poList->m_nKey;
    poList = poList->m_poNext;
    delete poList->m_poPrev;
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  StList oHead, oTrail;
  oHead.m_poNext  = &oTrail;
  oTrail.m_poPrev = &oHead;
 
  fnLinkedListSet(oHead, oTrail);
  fnLinkedListGet(oHead, oTrail);

  return 0;
}

Measured memory_bytes: 32456
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

void yes(){
   cout<<"Yes"<<endl;
   //exit (0);
}
void no(){
   cout<<"No"<<endl;
   //exit (0);   
}

int n, m;
string s, t;

int32_t main(){_

   int x;
   cin >> n >> m >> x;

   vector<int> cost;
   vector<vector<int>> v;
   for (int i = 0; i < n; ++i)
   {
      int x;
      cin >> x;
      cost.push_back(x);

      vector<int> t;
      for (int j = 0; j < m; ++j)
      {
         int y;
         cin >> y;
         t.push_back(y);
      }

      v.push_back(t);
   }

   int ret = inf;

   for (int i = 0; i < (1LL << n); ++i)
   {
      vector<int> which;
      for (int j = 0; j < n; ++j)
      {
         if (i & (1LL << j)){
            which.push_back(j);
         }
      }

      int curr = 0;
      //  >= x;

      vector<int> ans(m, 0);
      for(auto books: which)
      {
         int ptr = 0;
         curr += cost[books];
         for(auto it: v[books]){
            ans[ptr++] += it;
         }
      }

      bool good = 1;
      for (int i = 0; i < m; ++i)
      {
         good  &= ans[i] >= x;
      }

      if (good){
         smin(ret, curr);
      }
   }

   if (ret == inf){
      cout<<-1;
   }
   else{
      cout<<ret;
   }
   

   return 0;
}

Measured memory_bytes: 3664
def solve(s):
    if s[0] != "A":
        return False

    if s[2:-1].count("C") != 1:
        return False

    i = 2 + s[2:-1].index("C")
    t = s[1:i] + s[i + 1 :]
    return t == t.lower()


s = input()
print("AC" if solve(s) else "WA")


Measured memory_bytes: 2940
// Problem : C - H and V
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_c
// Memory Limit : 1024 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 100005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub uppper_bound
using namespace std;
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int n,m,k;
int row[6],col[6];
string arr[6];
int ans = 0,tot=0;

void cal(vector<int> v,vector<int> f)
{
	int cnt = 0;
	rep(i,0,n)
	{
		if(v[i] == 1)
			cnt+=row[i];
	}
	rep(i,0,m)
	{
		if(f[i] == 1)
			cnt+= col[i];
	}
	rep(i,0,n)
	{
		rep(j,0,m)
		{
			if(v[i] == 1 and f[j] == 1 and arr[i][j] == '#')
			cnt -= 1;
		}
	}
	if(tot - cnt == k)
		ans++;
}
void fun1(vector<int> v, vector<int> f, int ind)
{
	if(f.size() == ind)
	{
		cal(v,f);
		return;
	}
	f[ind] = 1;
	fun1(v,f,ind+1);
	f[ind] = 0;
	fun1(v,f,ind+1);
}
void fun(vector<int> v,int ind)
{
	if(ind == v.size())
	{
		vector<int> f(m,0);
		fun1(v,f,0);
		return;
	}
	v[ind]=1;
	fun(v,ind+1);
	v[ind]=0;
	fun(v,ind+1);
}
void solve()
{
	cin >> n >> m >> k;	
	rep(i,0,n)
		cin >> arr[i];
	rep(i,0,n)
	{
		int cnt=0;
		rep(j,0,m)
			if(arr[i][j] == '#')
				cnt++,tot++;
		row[i]=cnt;
	}
	rep(i,0,m)
	{
		int cnt=0;
		rep(j,0,n)
			if(arr[j][i] == '#')
				cnt++;
		col[i]=cnt;
	}
	vector<int> v(n,0);
	fun(v,0);
	cout  << ans ;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n, k, l;
int a[] = { 1,2,3,4,5,6,7,8 };
int b[10], c[10];
bool flag1 = true;
bool flag2 = true;
int main(void)
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
	}
	int t = 0;
	do {
		flag1 = flag2 = true;
		for (int i = 0; i < n; i++)
		{
			if (b[i] != a[i])
			{
				flag1 = false;
			}
			if (a[i] != c[i])
			{
				flag2 = false;
			}
		}
		if (flag1)
		{
			k = t;
		}
		if (flag2)
		{
			l = t;
		}
		t++;
	} while (next_permutation(a, a + n));
	cout << abs(k - l) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) std::cerr<<"L: \t"<<__LINE__<<"\t f("<<__FUNCTION__<<")\t Var: \t"<<#x<<" \tVal: "<<x<<"\n";
typedef long long ll;
const int inf = 0x7f7f7f7f;

inline void gettime() {
	debug("Time: ");
	debug(clock());
}
inline int read() {
	static char c;
	static int x;
	while (c = getchar(), !isdigit(c));
	x = c - '0';
	while (c = getchar(), isdigit(c))
		x = (x << 1) + (x << 3) + c - '0';
	return x;
}
inline char achar() {
	static char c;
	while (c = getchar(), !isalpha(c));
	return c;
}

int n, m, bx, by, x = 1, y = 1;
int ns[600][600];

void next() {
	bx = x, by = y;
	if (x & 1) {
		++y;
		if (y > m)
			y = m, ++x;
	} else {
		--y;
		if (y == 0)
			y = 1, ++x;
	}
}

int cnt;
int step[1000000][4];
void store() {
	++cnt;
	int *p = step[cnt];
	p[0] = bx;
	p[1] = by;
	p[2] = x;
	p[3] = y;
}

int main() {
#ifndef ONLINE_JUDGE
	std::atexit(gettime);
#endif

	n = read(), m = read();
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			ns[i][j] = read();

	while (x <= n) {
		while (x <= n && ns[x][y] % 2 == 0) next();
		for (next(); x <= n && ns[x][y] % 2 == 0; next())
			store();
		if (x <= n) {
			store();
			next();
		}
	}

	printf("%d\n", cnt);
	for (int i = 1; i <= cnt; ++i)
		printf("%d %d %d %d\n", step[i][0], step[i][1], step[i][2], step[i][3]);
}

Measured memory_bytes: 6528
//============================================================================
// Name        : ITP_1_5_D.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int n,x;
	cin >> n;
	for(int i=1;i<=n;++i) {
		if(i%3==0) {
			printf(" %d",i);
		} else {
			for(x=i;x>0;x/=10) {
				if(x%10==3) {
					printf(" %d",i);
					break;
				}
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3212
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mask = (1 << 5) - 1;
const int mod = 1e9 + 7;
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int H, W;
	scanf("%d", &H);
	scanf("%d", &W);

	ll dp[1001];
	dp[0] = 1;
	char A[1001];
	scanf("%s", A);
	rep1(w, W - 1) dp[w] = (A[w] == '.' ? dp[w - 1] : 0);

	rep1(h, H - 1) {
		scanf("%s", A);
		dp[0] = (A[0] == '.' ? dp[0] : 0);
		rep1(w, W - 1) {
			dp[w] = (A[w] == '.' ? dp[w] + dp[w - 1] : 0);
			if (!(h + w & mask)) dp[w] %= mod;
		}
	}
	printf("%d", dp[W - 1] % mod);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int64_t n;
    cin >> n;
    cout << (n - 1) * n / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
int H, N, A;
int B = 0;
cin >> H >> N;
for(int n = 0; n < N; n++){
cin >> A;
B = B + A;
}
if(B >= H){
    cout<<"Yes";
}
else{
    cout<<"No";
}
}

Measured memory_bytes: 256
#include<iostream>

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

  const int MAX_COINS = 100000;
  int coins[n + 1];
  for(int i = 0; i < n + 1; i++) coins[i] = MAX_COINS;
  
  for(int i = 0; i < m; i++){
    int c;
    std::cin >> c;
    if(c <= n) coins[c] = 1;
  }

  for(int i = 1; i <= n; i++){
    if(coins[i] != MAX_COINS) continue;
    for(int k = i - 1; k >= 1; k--){
      coins[i] = std::min(coins[i], coins[k] + coins[i - k]);
    }
  }

  std::cout << coins[n] << std::endl;
  
  return 0;
}



Measured memory_bytes: 3268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int a, b, s, l;
		
		a = scan.nextInt();
		b = scan.nextInt();
		s = a*b;
		l = (a+b)*2;		
		
		
		System.out.println(s +" "+l);
	}

}



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

int main() {
    long long a, b;
    cin >> a >> b;

    long long ans;
    for (long long i = 1; i <= b; i++) {
        if ((i * a) % b == 0) {
            ans = i * a;
            break;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

// #define DEBUG

typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;

const int NMAX = 1005;
const int MMAX = 2e8;

const ll INFLL = 1e18;
const int INF = 1e9;


ll N,M,K;
int A[NMAX] = {};
int dp[5][NMAX] = {};
std::vector<int> table;

int ans = 0;

int solve(){
  sort(A, A + N);
  for(int i = 0; i < N ; ++i) dp[1][i] = (A[i] <= M ? A[i] : 0);
  for (int k = 2; k <= 4; ++k)
  {
    for (int i = 0; i < N; ++i)
    {
      if (dp[k-1][i] + A[i] <= M)
      {
        dp[k][i] = dp[k-1][i] + A[i];
      }else{
        int* ite = upper_bound(A, A + i, M - dp[k-1][i]);
        if(ite != A) {
          dp[k][i] = dp[k-1][i] + *(--ite);
        }
        else {
          dp[k][i] = dp[k-1][i];
        }
      }
      if(i) dp[k][i] = max(dp[k][i-1], dp[k][i]);
    }
  }
  return dp[4][N-1];
}
int solve2(){
  table.clear();
  table.reserve((N+1)*(N+1));
  for (int i = 0; i < N + 1; ++i)
  {
    for (int j = 0; j < N + 1; ++j)
    {
      table.push_back(A[i] + A[j]);
    }
  }
  sort(table.begin(), table.end());

  ans = 0;
  for (int i = 0; i < (N + 1) * (N + 1); ++i)
  {
    int target = M - table[i];
    auto ite = upper_bound(table.begin(), table.end(), target);
    if (ite != table.begin())
    {
      ans = max(ans, table[i] + *(--ite));
    }
  }
  return ans;
}
void debug(){
  cout << "dp:\n";
  for (int i = 0; i < 4; ++i)
  {
    for (int j = 0; j < N; ++j)
    {
      cout << dp[i+1][j] << " ";
    }
    cout << endl;
  }
}

int main(int argc, char const *argv[])
{
  while(1) {
      cin >> N >> M;
      if(N == 0 && M == 0) break;
      memset(A, 0, sizeof(A));
      for (int i = 0; i < N; ++i)
      {
        scanf("%d", &A[i+1]);
      }
      cout << solve2() << endl;
      #ifdef DEBUG
      // debug();
      #endif
  }

  return 0;
}

Measured memory_bytes: 6712