akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

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

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <limits.h>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<lint> vl;
typedef pair<lint,lint> pll;

void solve(){

}

int main()
{
    ios_base::sync_with_stdio(0);    cin.tie(NULL);    cout.tie(NULL);


    string s; cin>>s;
    for (char &c : s) if (c=='?') c='D';
    cout<<s;




}


Measured memory_bytes: 3744
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
  int d, n, b;
  cin >> d >> n >> b;
  int p[n], h[n];
  for(int i = 0; i < n; ++i){
    cin >> p[i] >> h[i];
  }
  double INF = 1E15, ans = INF;
  for(int i = 0; i <= b; ++i){
    double m = (double)d/(i+1)/2.0, p_, g = 1.0, t = 0.0;
    //cout << "m = " << m << endl;
    for(int j = 0; j < n; ++j){
      p_ = p[j];
      while(p_-2*m >= 0.0){
        p_ -= 2*m;
      }
      if(p_ > 1.0/INF){
        double a = h[j]/(m*m - (p_-m)*(p_-m));
        //cout << "a = " << a << endl;
        t = max(t,2*a*m);
      }else{
        t = INF;
        break;
      }
    }
    //cout << "t = " << t << endl;
    if(t < 1){
      //cout << "sqrt(2*m*g) = " << sqrt(2*m*g) << endl;
      ans = min(ans, sqrt(2*m*g));
    }else{
      //cout << "sqrt(m*g*(t+1.0/t)) = " << sqrt(m*g*(t+1.0/t)) << endl;
      ans = min(ans, sqrt(m*g*(t+1.0/t)));
    }
  }
  printf("%.12f\n",ans);
  return 0;
}

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

int main () {
	
	int n=0, m=0, k=0, x=0, i=0, j=0;

	cin >> n >> m;

	int arr[m];

	memset(arr, 0, sizeof(arr));

	for (i=0; i<n; i++) {
		cin >> k;
		for (j=0; j<k; j++) {
			cin >> x;
			arr[x-1]++;
		}
	}

	int res=0;
	for (i=0; i<m; i++) 
		if (arr[i] == n)
			res++;

	cout << res << endl; 

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll modpow(ll a, ll n, ll m){
    if(n == 0) return 1;
    ll half = modpow(a,n/2,m);
    ll res = half * half % m;
    if(n & 1) res = res * a % m;
    return res;
}

int main(){
    int N; cin >> N;
    vector<vector<int>> A(N);
    rep(i,N){
        ll a; cin >> a;
        while(a > 0){
            int d = a%2;
            A[i].push_back(d);
            a /= 2;
        }
        while(A[i].size() < 60){
            A[i].push_back(0);
        }
    }
    ll ans = 0;
    rep(j,60){
        int cnt = 0;
        rep(i,N){
            if(A[i][j] == 1) cnt++;
        }
        ans += (ll)cnt*(N-cnt)%MOD*modpow(2,j,MOD)%MOD;
        ans %= MOD;
    }
    cout << ans << endl;

}


Measured memory_bytes: 86912
i = 0
line = gets
a,b,c = line.split(/\s/).map(&:to_i)
# puts a.integer?
# puts b.integer?
# puts c.integer?
(a..b).each do |num|
  # puts c
  # puts num
  if c % num == 0
    i = i + 1
  end
  # puts "each??????i?????????#{i}??§???"
end 
# puts "each??????i?????????#{i}??§???"
puts i

Measured memory_bytes: 6872
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> d(N, 0);
  for (int i = 0; i < N; i++) {
	cin >> d[i];
  }
  
  vector<int> num(100, 0);
  for (int i = 0; i < N; i++) {
	num[d[i] - 1]++;
  }
  
  int count = 0;
  for (int i = 0; i < 100; i++) {
	if (num[i] > 0) count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
S = input()

res = 'Yes'
if len(S) % 2 != 0:
  res = 'No'
else:
  cnt = len(S) // 2
  for i in range(cnt):
    if S[i * 2 : i * 2 + 2] == 'hi':
      continue
    else:
      res = 'No'

print(res)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SIZE 200005
#define Z(x) (((x)>0)?(x):0)
#define INF 100000000000000000LL

using namespace std;
typedef long long int ll;
typedef pair <ll,int> P;

int main(){
    int N;
    cin>>N;
    bool isprime[105];
    vector<int> prime;//素数の列
    vector<int> count;
    int plen = 0;
    isprime[0]=isprime[1]=0;
    for(int i = 2; i <= 100;i++){
        isprime[i]=1;
        for(int j = 2;j < i;j++){
            if(isprime[j]&&i%j==0){
                isprime[i]=0;
                break;
            }
        }
    }
    for(int i = 0; i <= 100;i++){
        if(isprime[i]){
            prime.push_back(i);
        }
    }
    plen = prime.size();count.resize(plen,0);
    
    for(int i = 1; i <= N;i++){
        int temp = i;
        int pindex = 0;
        while(temp>1){
            if(temp%prime[pindex]==0){
                temp /= prime[pindex];
                count[pindex]++;
            }else{
                pindex++;
            }
        }
    }
//    rep(i,count.size()){
//        cout<<count[i]<<" ";
//    }
//    cout<<endl;
    reverse(count.begin(),count.end());
    int ans = 0;
    int up74 = (count.end()-lower_bound(count.begin(),count.end(),74));
    int up24 = (count.end()-lower_bound(count.begin(),count.end(),24));
    int up14 = (count.end()-lower_bound(count.begin(),count.end(),14));
    int up4 = (count.end()-lower_bound(count.begin(),count.end(),4));
    int up2 = (count.end()-lower_bound(count.begin(),count.end(),2));
//    cout<<up2<<" "<<up4<<" "<<up14<<" "<<up24<<endl;
    ans += up74;
    ans += up24*Z(up2-1);
    ans += up14*Z(up4-1);
    ans += up4*Z(up4-1)*Z(up2-2)/2;
    cout<<ans<<endl;
}


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

int n,ma,mb,i,j,k;
int a[41],b[41],c[41];
int costa[500][500],costb[500][500];
int anscost=1000000;
int halfn=n/2;

int ans=anscost;  
int saidai=410;  

int main(){
scanf("%d %d %d",&n,&ma,&mb);
for (i=0;i<n;i++){
  scanf("%d %d %d",&a[i],&b[i],&c[i]);
  //printf("%d %d\n",a[i],b[i]);
}

//printf("%d\n",saidai);
//printf("%d %d\n",a[0],b[0]) ; 
     for (j =0;j<500*500;j++){
         costa[j/500][j%500]=anscost;
         costb[j/500][j%500]=anscost;
     //printf("%d\n",saidai);
     }
     //printf("%d\n",0);
   //  printf("%d\n",saidai);
     costa[0][0]=0;
     costb[0][0]=0;
  for ( i=0;i<halfn;i++){
     for (j =saidai*saidai-1;j>=0;j--){
     //  printf("%d %d %d %d %d %d\n",j/saidai+a[i],j%saidai+b[i],a[i],b[i],a[0],b[0]);
       if (  (costa[j/saidai][j%saidai]!=anscost) ){
         costa[j/saidai+a[i]][j%saidai+b[i]]=min(costa[j/saidai+a[i]][j%saidai+b[i]],costa[j/saidai][j%saidai]+c[i]);
         
       }
     }
  }
  for ( i=halfn;i<n;i++){
     for (j =saidai*saidai-1;j>=0;j--){
       if ( (costb[j/saidai][j%saidai]!=anscost)){
         costb[j/saidai+a[i]][j%saidai+b[i]]=min(costb[j/saidai+a[i]][j%saidai+b[i]],costb[j/saidai][j%saidai]+c[i]);
       }
     }
  }
//for (i=0;i<saidai*saidai;i++){printf("%d\n",costa[i/saidai][i%saidai]);}
  //   printf("%d\n",saidai);
for (i=1;i*ma<saidai;i++){
  for (j=0;j<=i*ma;j++){
    for (k=0;k<=i*mb;k++){
      if ( costa[j][k]!=anscost && costb[i*ma-j][i*mb-k]!=anscost){
        if (ans>costa[j][k]+costb[i*ma-j][i*mb-k]){ans=costa[j][k]+costb[i*ma-j][i*mb-k];}
      }
    }
  }
}
//printf("%d\n",ans);
if (ans!=anscost){printf("%d\n",ans);}
else {printf("%d\n",-1);};  


}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

int main(){
    ll x;
    cin >> x;

    
    ll ans = (x / 11) * 2;
    if(0 < x % 11 && x % 11 <= 6) ans += 1;
    else if(7 <= x % 11) ans += 2;

    cout << ans << endl;

    return 0;
}

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

string S;

int find_XX(string s) {
  int n = s.size();
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == s[i + 1]) {
      return i;
    }
  }
  return -1;
}

int find_XYX(string s) {
  int n = s.size();
  for (int i = 0; i < n - 2; i++) {
    if (s[i] == s[i + 2]) {
      return i;
    }
  }
  return -1;
}

void solve() {
  int check1 = find_XX(S);
  int check2 = find_XYX(S);

  if (check1 != -1) {
    cout << check1 + 1 << " " << check1 + 2 << "\n";
    return;
  }
  else if (check2 != -1) {
    cout << check2 + 1 << " " << check2 + 3 << "\n";
    return;
  }
  else {
    cout << "-1 -1\n";
    return;
  }
}

int main() {
  cin >> S;
  solve();
  return 0;
}

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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int N;
    cin >> N;
    if(N == 0) {
        cout << 0 << endl;
        return 0;
    }
    string ans = "";
    while(abs(N) > 0) {
        int d = abs(N) & 1 ? 1 : 0;
        N -= d;
        N /= -2;
        ans = (d ? "1" : "0") + ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				System.out.println(i+"x"+j+"="+i*j);
			}
		}
	}

}

Measured memory_bytes: 16844
#include<bits/stdc++.h>
using namespace std;
int main(){
	int H,W; cin>>H>>W;
	vector<string>a(H);
	map<char,int> cnt;
	int tot = H*W;
	for(int i=0;i<H;i++){
		cin>>a[i];
		for(int j=0;j<W;j++){
			cnt[a[i][j]]++;
		}
	}
	int two=0, one=0;
	for(int i=0;i<26;i++){
		if(cnt[i+'a']%2){
			one++, cnt[i+'a']--;
		}
	}
	if(one && H*W%2==0 || one>1){
		cout<<"No\n";
		return 0;
	}
	if(H%2) 
		two+=W/2;
	if(W%2) 
		two+=H/2;
	int four = (H*W-(H*W%2)-two * 2)/4;
	for(int i=0;i<26;i++){
		four -= cnt[i+'a']/4;
	}
	if(four>0) cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scan_init()
	l := scanInt()
	r := scanInt()
	d := scanInt()
	count := 0
	i:= 1
	for {
		if (i*d <= r) {
			if (l<=i*d) {
				count ++
			}
			i ++
		} else {
			break
		}
	}
	fmt.Println(count)
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1772
#include<stdio.h>
int main(){
  int a,b,c;
  char op;
  for(;;){
    scanf("%d %c %d",&a,&op,&b);
    if(op == '+'){
      c=a+b;
    }else if(op == '-'){
      c=a-b;
    }else if(op == '*'){
      c=a*b;\
    }else if(op == '/'){
      c=a/b;
    }else {if(op=='?')break;
    }
    printf("%d\n",c);
  }
  return 0;
}
    

Measured memory_bytes: 600
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let Q = read!(i32, i32, i32; N);

    for cx in 0..101 {
        for cy in 0..101 {
            let mut mi_h = 1;
            let mut ma_h = 1_000_001_000;

            for &(x, y, h) in &Q {
                let d = (x - cx).abs() + (y - cy).abs();
                if h == 0 {
                    ma_h = min(ma_h, d);
                } else {
                    mi_h = max(mi_h, d + h);
                    ma_h = min(ma_h, d + h);
                }
            }

            if mi_h == ma_h {
                println!("{} {} {}", cx, cy, mi_h);
                return;
            }
        }
    }
    panic!("could not solve")
}

/*

1
0 0 1000000000

2
100 0 1000000000
0 100 1000000000
100 100 9999999900

0 0 1000000100

*/


Measured memory_bytes: 4352
a, b = map(int, input().split())

def calc(x):
    x += 1
    ans = 0
    for i in range(40):
        loop = 1<<(i+1)
        cnt = (x//loop)*(loop//2)
        cnt += max(0, (x%loop)-(loop//2))
        if cnt%2 == 1:
            ans += 1<<i
    return ans

ans = calc(b)^calc(a-1)
print(ans)

Measured memory_bytes: 38256
#![allow(dead_code, unused_imports, non_snake_case)]

use std::io::*;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::str::FromStr;

const MOD: i32 = 1_000_000_007;

fn main() {
    let (n, m): (usize, u64) = input();
    let mut v: Vec<u64> = input();
    for i in 1..n { v[i] += v[i - 1]; }

    let mut map: BTreeMap<u64, u64> = BTreeMap::new();
    map.insert(0, 1);

    for x in v {
        let c = map.entry(x % m).or_insert(0);
        *c += 1;
    }

    let mut ans: u64 = 0;
    for &cnt in map.values() {
        ans += cnt * (cnt - 1) / 2;
    }
    println!("{}", ans);
}

trait Read {
    fn read(s: &str) -> Self;
}

fn input<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl {
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}

Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<pair<int,int>>v(n);
	for(int i=0;i<n;i++){
		int x,l;
		cin>>x>>l;
		v[i]={x+l,x-l};
	}
	sort(v.begin(),v.end());
		int ans=0;
		int cnt=INT_MIN;
		for(int i=0;i<n;i++){
			if(v[i].second>=cnt){
				ans++;
				cnt=v[i].first;
			}
		}
		cout<<ans<<endl;
		return 0;
}

Measured memory_bytes: 1024
def main():
    A,V = [int(x) for x in input().split()]
    B,W = [int(x) for x in input().split()]
    T = int(input())
    D = abs(A-B)
    if V<=W:
        print('NO')
        return
    F = V-W
    if D/F <= T:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

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

int main(){
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  vector<int>xr(n);
  vector<int>yr(m);
  for(int i=0;i<n;i++)
    cin >> xr.at(i);
  for(int i=0;i<m;i++)
    cin >> yr.at(i);
  sort(xr.begin(),xr.end(),greater());
  sort(yr.begin(),yr.end());
  cout << ((xr.at(0)<yr.at(0)&&x<y&&xr.at(0)<y&&x<yr.at(0))?"No War":"War") << endl;
  return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int a, b, c; cin >> a >> b >> c;
  cout << a * b / 2 << endl;
}


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

int n;
long long a[50];

bool check(){
    for(int i = 0;i < n;i++){
        if(a[i] >= n) return false;
    }
    return true;
}

int big(){
    int maxi = 0,maxn = 0;
    for(int i = 0;i < n;i++){
        if(a[i] > maxi){
            maxi = a[i];
            maxn = i;
        }
    }
    return maxn;
}

long long solve(){
    long long ans = 0;
    for(int i = 0;i < n;i++){
        if(a[i] > n*(n+1)){
            long long ki = a[i] / (n*(n+1));
            ans += n*(n+1)*(ki-1);
            a[i] -= n*(n+1)*(ki-1);
        }
    }
    while(true){
        if(check()) return ans;
        int k = big();
        for(int i = 0;i < n;i++) a[i]++;
        a[k] -= n+1;
        ans++;
    }
}

int main() {
    cin >> n;
    for(int i = 0;i < n;i++) cin >> a[i];
    cout << solve() << endl;
}


Measured memory_bytes: 256
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;

int main()
{
    ll a;
    string s;
    cin>>a>>s;
    if(a>=3200)cout<<s;
    else cout<<"red";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int a,b;
inline int read(){
	int x=0,t=1,c;
	while(!isdigit(c=getchar())) if(c=='-') t=-1;
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return x*t;
}
int main(){
	a=read(),b=read();
	printf("%d\n",max(a,b)+max(max(a,b)-1,min(a,b)));
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main() {
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	int ans;
	int d = a[n - 1] - a[0];
	if (k / 2 < d)d = k - d;
	for (int i = 1;i < n;i++) {
		if (d < a[i] - a[i - 1])d = a[i] - a[i - 1];
	}
	ans = k - d;
	cout << ans << endl;
	return 0;
}


//BBBBBBBBBBBBBBBBBBB
//int main() {
//	int x;
//	cin >> x;
//	long long _500 = x / 500;
//	long long _5 = x % 500 / 5;
//	long long ans = _500 * 1000 + _5 * 5;
//
//	cout << ans << endl;
//	return 0;
//}


//AAAAAAAAAAAAAAAAAAA
//int main() {
//	string s;
//	cin >> s;
//	if (s[2] == s[3] && s[4] == s[5])cout << "Yes" << endl;
//	else cout << "No" << endl;
//
//	return 0;
//}

Measured memory_bytes: 4048
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


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

int main()
{
    int x;
    io >> x;
    int ans = (x == 0) ? 1 : 0;
    io << ans << BR;
}

Measured memory_bytes: 3808
// abc152_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int a, b;
    cin >> a >> b;

    string x;
    REP(i, b) x += to_string(a);

    string y;
    REP(i, a) y += to_string(b);

    if (x < y){
        print(x);
    } else {
        print(y);
    }

    return 0;
}


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

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define INF 1000000005

using namespace std;

int ans;
int N;
int A[100005];

int solve() {
	sort(A, A + N);
	while ( A[0] != 0 && N > 1 ) {
		int zero = 0;
		REP(i, 1, N) {
			A[i] %= A[0];
			if ( A[i] == 0 ) {
				A[i] = INF;
				zero++;
			}
		}
		sort(A, A + N);
		N -= zero;
	}
	return A[0];
}

int main(void) {
    scanf("%d", &N);
    REP(i, 0, N) scanf("%d", &A[i]);

    printf("%d\n", solve());

	return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
from itertools import product
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    cur_max = A[0]
    count = 1
    for i in range(1,N):
        if cur_max < A[i]:
            cur_max = A[i]
            count += 1
    
    if count >= K:
        print(0)
        return
    answer = 10**11

    for bit in product([0,1],repeat=N):
        cur_max = A[0]
        count = 1
        cost = 0
        for i in range(1,N):
            if cur_max < A[i]:
                cur_max = A[i]
                count += 1
            else:
                if bit[i] == 1:
                    cost += cur_max+1-A[i]
                    cur_max += 1
                    count += 1

        if count >= K:
            answer = min(answer,cost)
    print(answer)


    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  																						   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;	
const int mod = 1e9+7;																							   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	string s;
	cin >> s;
	for(int i = 0 ;i < s.size(); i++){
		if(s[i] == '9'){
			s[i] = '1';
		}
		else if(s[i] == '1'){
			s[i] = '9';
		}
	}

	cout << s << endl;
						
	return 0;
}


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

using namespace std;

struct edge {
  int dest;
  int weight; // = dest minus curr
};

class UF {
public:
  vector<edge> v;
  UF(int n) { v = vector<edge>(n, {-1, 0}); }
  void unite(int x, int y, int y_minus_x) {
    int loc_x = find(x);
    int loc_y = find(y);
    if (loc_x == loc_y)
      return;
    if (v[loc_x].dest <
        v[loc_y].dest) { // x's set has more elements -- join y to x
      v[loc_x].dest += v[loc_y].dest;
      v[loc_y] = {loc_x, -y_minus_x};
    } else {
      v[loc_y].dest += v[loc_x].dest;
      v[loc_x] = {loc_y, y_minus_x};
    }
  }
  void unite(int x, int y) { unite(x, y, 0); }

  // if weighted = true, returns the difference of the root and the current node
  // if weighted = false, returns the id of the root
  int find(int x, bool weighted = false) {
    int tmp = 0;
    while (v[x].dest >= 0) {
      tmp += v[x].weight;
      x = v[x].dest;
    }
    return (weighted ? tmp : x);
  }
  // pre: x and y are in the same set
  // post: returns y - x
  int get_difference(int x, int y) {
    int root_minus_x = find(x, true);
    int root_minus_y = find(y, true);
    return root_minus_x - root_minus_y;
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  UF uf(n);
  int c, x, y;
  while (cin >> c >> x >> y) {
    if (c == 0)
      uf.unite(x, y);
    if (c == 1)
      cout << (uf.find(x) == uf.find(y)) << endl;
  }
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    ll n,x;
    ll a[3777] = {};
    Scll2(n,x);
    Rep(i,n){
        Scll(a[i]);
    }

    ll ans[3334] = {};
    fill(ans,ans+n,INF*66661111);
    ll answer = 0;

    /*
    ll trans = 0;
    Rep(i,n){
        for( int j = i+n; j > i; j--){
            //スライムj から スライムi を作れ！
            //答え：ちょっと惜しい　魔法の回数をちゃんと考えるとよい
            if( ans[i] > a[j%n] + x * ( (j-i+n) % n )){
                ans[i] = a[j%n];
                trans = max<ll>( (j-i+n)%n ,trans);
            }
        }
        answer += ans[i];
    }*/

    ll fa = INF*333111999;
    Rep(mag,n){
        answer = 0;
        Rep(i,n){
            ans[i] = min<ll>(a[(i-mag+n)%n] , ans[i]);
            answer += ans[i];
        }
        fa = min<ll>(fa,answer+mag*x);
    }

    printf ("%llu\n", fa );




    return 0;
}



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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    lint dp[101][4][4][4] = {0};
    rep(j, 4){
        rep(k, 4){
            rep(l, 4){
                if((j == 0 && k == 1 && l == 2) || (j == 0 && k == 2 && l == 1) || (j == 2 && k == 0 && l == 1)){
                    dp[3][j][k][l] = 0;
                }else{
                    dp[3][j][k][l] = 1;
                }
            }
        }
    }

    REP(i, 3, n){
        rep(j, 4){
            rep(k, 4){
                rep(l, 4){
                    rep(m, 4){
                        if((j == 0 && m == 1 && (k == 2 || l == 2)) || (k == 0 && l == 2 && m == 1) || (k == 0 && l == 1 && m == 2) || (k == 2 && l == 0 && m == 1)){
                            continue;
                        }
                        dp[i + 1][k][l][m] += dp[i][j][k][l];
                        dp[i + 1][k][l][m] %= MOD;
                    }
                }
            }
        }
    }

    lint ans = 0;
    rep(j, 4){
        rep(k, 4){
            rep(l, 4){
                ans += dp[n][j][k][l];
                ans %= MOD;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

ans = -1
for i in range(max(x)):
    tmp_ans = 0
    for j in range(n):
        tmp_ans += (x[j]-(i+1))**2
    if ans == -1:
        ans = tmp_ans
    else:
        ans = min(ans, tmp_ans)
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

//先行順巡回
void preParse(int u){
    if( u == NIL ) return;
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}

//中間順巡回
void inParse(int u){
    if( u == NIL ) return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

//後行順巡回
void postParse(int u){
    if( u == NIL ) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

using namespace std;
int main(){
    int v, l, r, root;

    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        T[i].p = NIL;
    }

    for(int i = 0; i < n; ++i){
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if( l != NIL ) T[l].p = v;
        if( r != NIL ) T[r].p = v;
    }

    for(int i = 0; i < n; ++i) if(T[i].p == NIL) root = i;

    printf("Preorder\n");
    preParse(root);
    putchar('\n');
    printf("Inorder\n");
    inParse(root);
    putchar('\n');
    printf("Postorder\n");
    postParse(root);
    putchar('\n');

    return 0;
}

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

using namespace std;

int main()
{
    int M;
    while (cin >> M, M) {        
        int res = 0;
        const int coin[] = {500, 100, 100, 50, 10, 5, 1};
        M = 1000 - M;
        for (int i = 0; i < 7; i++) {
            while (M >= coin[i]) {
                M -= coin[i];
                res++;
            }
        }
        cout << res << endl;
    }
    return 0;
}

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

const int maxn=1005;
int a[maxn],s[maxn],n,m,b;
int f[maxn][maxn*5];

int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;++i) {
		scanf("%d %d",&a[i],&b);
		for(int j=1;j<=b;++j) {
			int t;
			scanf("%d",&t);
			s[i]+=1<<(t-1);
		}
	}
	memset(f,127,sizeof f);
	f[0][0]=0;
	for(int i=1;i<=m;++i) {
		for(int j=0;j<(1<<n);++j) {
			f[i][j]=min(f[i-1][j],f[i][j]);
			f[i][j|s[i]]=min(f[i-1][j]+a[i],f[i][j|s[i]]);
		}
	}
	if(f[m][(1<<n)-1]==f[m+1][0]) printf("-1");
	else printf("%d",f[m][(1<<n)-1]);
}

Measured memory_bytes: 19968
import java.io.*;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {
    //Solution by Sathvik Kuthuru
    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        for(int tt = 1; tt <= t; tt++) solver.solve(tt, scan, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            long a = scan.nextLong(), b = scan.nextLong(), c = scan.nextLong();
            if(c < b) {
                out.println(func(a, b, c));
            }
            else {
                out.println(Math.max(func(a, b, b - 1), func(a, b, b)));
            }
        }

        static long func(long a, long b, long x) {
            return a * x / b - a * (x / b);
        }
    }

    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

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

int main() {
	int h,w,ch=1;
	while(1){
		cin>>h>>w;
		if(h==0)
			break;
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				if(ch==1){
					cout<<'#';
					ch=0;
				}
				else{
					cout<<'.';
					ch=1;
				}
			}
			if(i%2)
				ch=0;
			else
				ch=1;
			cout<<'\n';
		}
		ch=1;
		cout<<'\n';
	}
	return 0;
}

Measured memory_bytes: 1120
K = int(input())

Ans = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for x in range(1,15):
    B = [0]*100000
    n,d = 10**x,int("9"*x)
    for i in range(10000):
        num = i*n+d
        S = str(num)
        total = 0
        for s in S:
            total += int(s)
        B[i] = num/total
        if i > 0:
            if B[i] < B[i-1]:
                #最後の値を削除
                Ans.pop()
                break
            else:
                if num not in Ans:
                    Ans.append(num)

for i in range(K):
    print(Ans[i])

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

using namespace std;

int gcd(int x, int y) {
    if (y == 0) return x;
    if (x < y) return gcd(y, x);
    else return gcd(y, x % y);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), l(n), r(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        if (i == 0) l[i] = a[i];
        else l[i] = gcd(a[i], l[i - 1]);
    }
    for (int i = n - 1; i >= 0; --i) {
        if (i == n - 1) r[i] = a[i];
        else r[i] = gcd(a[i], r[i + 1]);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (i == 0) {
            ans = max(ans, r[1]);
            continue;
        }
        if (i == n - 1) {
            ans = max(ans, l[n - 2]);
            continue;
        }
        ans = max(ans, gcd(l[i - 1], r[i + 1]));
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 1408
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s = itr.next().unwrap();
    let n = s.len();
    for i in 0..n {
        for j in i..n {
            let mut t = s[..i].to_string();
            t += &s[j..];
            if t == "keyence" {
                println!("YES");
                return;
            }
        }
    }
    println!("NO");
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

static const ll MAX = 501;
int coin[MAX][MAX] = {};
int ans[MAX*MAX][4];
int main() {
    
    int h,w;
    cin >> h >> w;
    for (int i=1;i<=h;i++){
        for (int j=1;j<=w;j++){
            cin >> coin[i][j];
        }
    }
    ll ind = 0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++) {
            if (coin[i][j] % 2 == 1) {
                if (j < w) {
                    ans[ind][0] = i;
                    ans[ind][1] = j;
                    ans[ind][2] = i;
                    ans[ind][3] = j+1;
                    ind += 1;
                    coin[i][j] -= 1;
                    coin[i][j + 1] += 1;
                } else if (i < h) {
                    ans[ind][0] = i;
                    ans[ind][1] = j;
                    ans[ind][2] = i+1;
                    ans[ind][3] = j;
                    ind += 1;
                    coin[i][j] -= 1;
                    coin[i + 1][j] += 1;
                }
            }
        }
    }
    cout << ind << endl;
    for (ll i=0;i<ind;i++){
        cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << endl;
    }

}



Measured memory_bytes: 6912
#include <cstdio>
#include <algorithm>
#include <cstring>

#define loop(n) for(ll i=0;i<n;i++)

using namespace std;

typedef long long int ll;

int main() {
    ll n,x[200000],y[200000];
    scanf("%lld",&n);
    loop(n) scanf("%lld",&x[i]);
    memcpy(y,x,sizeof(ll[200000]));
    sort(y,y+n);
    ll a[2] = {y[n/2-1],y[n/2]};
    loop(n) if(x[i] <= a[0]) printf("%lld\n",a[1]); else printf("%lld\n",a[0]);
}

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

typedef long long ll;
const ll MOD = 1000000007;

int n;
int X, Y, Z;
int XYZ;
int maxi;
// typedef pair<int,deque<int> > K;
typedef pair<int, ll> K;

bool isPossible(const deque<int>& vs) {
  int as[] = {X, Y, Z};
  int i = 0;
  for(int v : vs) {
    if(i >= 3) {
      return false;
    }
    as[i] -= v;
    if(as[i] < 0) {
      return false;
    } else if(as[i] == 0) {
      ++i;
    }
  }
  return i <= 3;
}

ll mypow(ll x, ll n) {
  if(n == 0) {
    return 1;
  } else if(n % 2 == 0){
    return mypow(x*x%MOD, n/2);
  } else {
    return mypow(x*x%MOD, n/2)*x%MOD;
  }
}

ostream& operator<<(ostream& out, const deque<int>& vs) {
  out << "{";
  for(int v : vs) {
    out << v << ",";
  }
  return out << "}";
}

ll encode(const deque<int>& vs) {
  ll res = 0;
  ll t = 1;
  for(int v : vs) {
    res = res + (v-1)*t;
    t *= 10;
  }
  return res + t*9;
}

map<K, ll> memo;
ll solve(int rest, const deque<int>& vs, int sum) {
  //  K key(rest, vs);
  K key(rest, encode(vs));
  if(memo.count(key)) {
    return memo[key];
  }
  ll res = 0;
  if(rest > 0) {
    for(int cur = 1; cur <= 10; ++cur) {
      deque<int> nextVs = vs;
      int nextSum = sum;
      nextVs = vs;
      nextSum = sum;
      nextVs.push_back(cur);
      nextSum += cur;
      while(!nextVs.empty() && (nextSum > XYZ || !isPossible(nextVs))) {
        nextSum -= nextVs.front();
        nextVs.pop_front();
      }
      if(nextSum == XYZ) {
        res = (res + mypow(10, rest-1)) % MOD;
      } else {
        res = (res + solve(rest-1, nextVs, nextSum)) % MOD;
      }
    }
  }
  // if(res > 0 && rest == 3) {
  //   cerr << "solve(" << rest << "," << vs << ") = " << res << endl;
  // }
  return memo[key] = res;
}

int main(void) {
  int n;
  scanf("%d%d%d%d", &n, &X, &Y, &Z);
  maxi = max(max(X, Y), Z);
  XYZ = X + Y + Z;
  deque<int> vs;
  ll res = solve(n, vs, 0);
  printf("%lld\n", res);
  
  return 0;
}


Measured memory_bytes: 36992
from bisect import bisect_left, bisect_right
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
na = a[:bisect_left(a, 0)]
pa = a[bisect_right(a, 0):][::-1]
mod = 10**9+7
if k==n:
    ans = 1
    for i in a:
        ans *= i
        ans %= mod
    print(ans)
    exit(0)
if k%2==1 and len(pa)==0:
    ans = 1
    for i in a[::-1][:k]:
        ans *= i
        ans %= mod
    print(ans)
    exit(0)
if k==1:
    print(a[-1])
    exit(0)
if k%2==1:
    rem = pa[-1]
    pa = pa[:-1]
na += [0]*n
pa += [0]*n
nn = 0
pn = 0
ans = 1
for i in range(k//2):
    if i==k//2-1 and k%2==1:
        break
    if pa[pn]*pa[pn+1]>=na[nn]*na[nn+1]:
        ans *= pa[pn]*pa[pn+1]
        pn += 2
    else:
        ans *= na[nn]*na[nn+1]
        nn += 2
    ans %= mod
if k%2==1:
    ans *= max(pa[pn]*pa[pn+1]*max(pa[pn+2], rem), na[nn]*na[nn+1]*max(pa[pn], rem))
print(ans%mod)

Measured memory_bytes: 107064
s=list(input())
n=len(s)
 
def dfs(i,f,su):
    if i==n-1:
        if su==7:
            print(f+"=7")
            exit()
    else:
        dfs(i+1,f+"+"+s[i+1], su+int(s[i+1]))
        dfs(i+1,f+"-"+s[i+1], su-int(s[i+1]))
 
 
print(dfs(0,s[0],int(s[0])))

Measured memory_bytes: 3064
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	vi students(30, 1);
	int tmp;

	REP(i, 28) {
		cin >> tmp;
		students[tmp-1] = 0;
	}

	REP(i, 30) {
		if(students[i]) {
			cout << i+1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0