akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int getDate(string s){
	if(s == "*") return -1;
	int ret = 0;
	int n = s.size();
	rep(i, n) {
		if(s[i] == '/') continue;
		ret *= 10;
		ret += (s[i]-'0');
	}
	return ret;
}

struct D
{
	string title, author;
	int date;
};

bool check(const D& d, const string& t, const string& a, int s, int e){
	bool b[4] = {};
	b[0] = d.title.find(t) != string::npos || t == "*";
	b[1] = d.author.find(a) != string::npos || a == "*";
	b[2] = d.date >= s || s == -1;
	b[3] = d.date <= e || e == -1;
	return b[0] && b[1] && b[2] && b[3];
}


int main(){
	int n;
	cin>>n;
	string a, b, c, d;
	vector<D> v;
	rep(i, n){
		cin>>a>>b>>c;
		v.pb({a, b, getDate(c)});
	}
	int q;
	cin>>q;
	rep(i, q){
		if(i != 0) cout<<endl;
		cin>>a>>b>>c>>d;
		rep(j, n){
			if(check(v[j],a,b,getDate(c),getDate(d))) cout<<v[j].title<<endl;
		}
	}
}

Measured memory_bytes: 3232
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
*/
//入力終了→Ctrl+D
import java.util.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int[][][][] dp = new int[n][4][4][4];
        int mod = 1000000007;
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                for (int l = 0; l < 4; l++) {
                    if ((j == 0 && k == 2 && l == 1) || (j == 0 && k == 1 && l == 2) || (j == 2 && k == 0 && l == 1))
                        continue;
                    dp[2][j][k][l] = 1;
                }
            }
        }
        for (int i = 2; i < n - 1; i++) {
            for (int j = 0; j < 4; j++) {
                for (int k = 0; k < 4; k++) {
                    for (int l = 0; l < 4; l++) {
                        for (int m = 0; m < 4; m++) {
                            if (check(j, k, l, m))
                                dp[i + 1][k][l][m] = (dp[i + 1][k][l][m] + dp[i][j][k][l]) % mod;
                        }
                    }
                }
            }
        }
        long ans = 0;
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                for (int k = 0; k < 4; k++) {
                    ans = (ans + dp[n - 1][i][j][k]) % mod;
                }
            }
        }
        out.println(ans);
    }

    static boolean check(int j, int k, int l, int m) {
        int a = 0, c = 1, g = 2, t = 3;
        if ((k == a && l == g && m == c) || (k == a && l == c && m == g) || (k == g && l == a && m == c)) return false;
        if ((j == a && k == g && l == c) || (j == g && k == a && l == c) || (j == a && k == c && l == g)) return false;
        if ((j == a && l == g && m == c) || (j == a && k == g && m == c)) return false;
        return true;
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  long long  arr[n];
  long long coin=1000;
  for(int i=0;i<n;i++)cin>>arr[i];
  for(int i=0;i<n-1;i++)
  { 
  	long long stock=0;
    if(arr[i]<arr[i+1])
    {
      stock=(coin/arr[i]);
      coin+=(arr[i+1]-arr[i])*stock;
    }

  }
  cout<<coin;
  return 0;
}

Measured memory_bytes: 3600
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n = int(input())
ans = 0

for i in range(1,n+1):
    if i%2 == 1 and len(make_divisors(i)) == 8:
        ans += 1

print(ans)


Measured memory_bytes: 9012
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

int main(){
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> vs(N, 0);
    rep(i, N){
        cin >> vs[i];
    }
    sort(vs.begin(), vs.end());


    queue<int> qs;
    rep(i, N){
        qs.push(vs[i]);
    }

    int cnt = 1;
    int ans = 1;
    int front = qs.front();
    qs.pop();
    while(! qs.empty()){
        int tmp = qs.front();
        if(tmp > K + front || cnt + 1 > C){
            front = tmp;
            ans ++;
            cnt = 0;
        }
        cnt ++;
        qs.pop();
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;

int main(){
  bool d[100001];
  int x;
  cin >> x;
  d[0] = true;
  for(int i = 0; i <= 100000;i++){
    if((i >= 100) && d[i-100])d[i] = true;
    if((i >= 101) && d[i-101])d[i] = true;
    if((i >= 102) && d[i-102])d[i] = true;
    if((i >= 103) && d[i-103])d[i] = true;
    if((i >= 104) && d[i-104])d[i] = true;
    if((i >= 105) && d[i-105])d[i] = true;
  }
  if(d[x]) cout << 1;
  else cout << 0;
}

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

int main() {

	ll n; cin >> n;
	vector<ll> a(n + 1, 0);
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
	ll sum = 0;
	for (ll i = 0; i <= n - 1; i++) {
		sum += abs(a[i + 1] - a[i]);
	}
	sum += abs(a[n]);
	for (ll i = 1; i <= n; i++) {
		ll tmpSum = 0;
		tmpSum += sum;
		tmpSum -= abs(a[i - 1] - a[i]);
		if (i != n) {
			tmpSum -= abs(a[i] - a[i + 1]);
			tmpSum += abs(a[i - 1] - a[i + 1]);
		}
		else {
			tmpSum -= abs(a[i]);
			tmpSum += abs(a[i - 1]);
		}
		cout << tmpSum << endl;
	}
	return 0;	
}

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


int main(void){
	int a,b;
	string s;
	cin >> a >> b >> s;
	for(int i = 0; i < a + b; ++i){
		if(i==a){
			if(s[i]!='-'){
				cout << "No"<< endl;
				return 0;
			}
		}else{
			if(!(s[i]-'0'>=0&&'9'-s[i]>=0)){
				cout << "No"<< endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
package main

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

type tower struct {
	high int
	good bool
}

func main() {
	sc.Split(bufio.ScanWords)
	n, m := nextInt(), nextInt()

	t := make(map[int]*tower, n)
	for i := 1; i <= n; i++ {
		t[i] = &tower{high: nextInt(), good: true}
	}

	for i := 1; i <= m; i++ {
		a, b := nextInt(), nextInt()
		if t[a].high < t[b].high {
			t[a].good = false
		} else if t[b].high < t[a].high {
			t[b].good = false
		} else {
			t[a].good = false
			t[b].good = false
		}
	}

	var c int
	for _, v := range t {
		if v.good {
			c++
		}
	}

	fmt.Println(c)
}

// =================================
// I/O util
// =================================

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

Measured memory_bytes: 8368
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    ll X, Y;
    cin >> X >> Y;
    string ans;
    ll diffAbso = X - Y >= 0 ? X - Y : Y - X;
    if (diffAbso <= 1) ans = "Brown";
    else ans = "Alice";

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>

#define MAX 1000000

bool prime[MAX];

void make(){
  for(int i = 0 ; i < MAX ; i++){
    prime[i] = true;
  }

  prime[0] = prime[1] = false;

  for(int i = 2 ; i*i < MAX ; i++){
    if(prime[i]){
      for(int j = 2*i ; j < MAX ; j += i){
	prime[j] = false;
      }
    }
  }
}

int main(){
  make();
  int n;
  while(scanf("%d" ,&n),n){
    int cnt = 0;
    for(int i = 2 ; i+i <= n ; i++){
      if(prime[i] && prime[n-i]){
	cnt++;
      }
    } 
    printf("%d\n" ,cnt);
  }

  return 0;
}

Measured memory_bytes: 2004
from collections import defaultdict
H, W, N = map(int, input().split())


D = defaultdict(int)
for i in range(N):
    h, w = map(int, input().split())
    h, w = h - 1, w - 1
    for dh in range(-1, 2):
        for dw in range(-1, 2):
            if not ((1 <= h + dh < H - 1) and (1 <= w + dw < W - 1)):
                continue
            D[(h + dh, w + dw)] += 1

ans = [0] * 10
for v in D.values():
    ans[v] += 1

ans[0] = (H - 2) * (W - 2) - sum(ans[1:])
print(*ans, sep='\n')


Measured memory_bytes: 166896
import datetime
for i in range(3):
    h1,m1,s1,h2,m2,s2=map(int,input().split())
    t_c=datetime.datetime(2019,3,7,h1,m1,s1)
    t_b=datetime.datetime(2019,3,7,h2,m2,s2)
    t_a=str(t_b-t_c)
    ha,hb,hc=map(int,t_a.split(":"))
    print(ha,hb,hc)


Measured memory_bytes: 6044
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



n,m = map(int, input().split())
from collections import defaultdict
ns = defaultdict(set)

for i in range(m):
    u,v = map(int, input().split())
    u -= 1 
    v -= 1
    ns[u].add(v)
    ns[v].add(u)

from queue import deque
start = 0
q = deque([start])
seen = [None] * n
seen[start] = 0
while q:
    u = q.pop()
    d = seen[u]
    for v in ns[u]:
        if seen[v] is None:
            seen[v] = u
            q.appendleft(v)
print("Yes")
print("\n".join(map(lambda x:str(x+1), seen[1:])))

Measured memory_bytes: 132368
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main( void )
{
	long long n;
	while ( cin >> n && n != 0 )
	{
		ostringstream os;
		os << oct << n;
		string n_str = os.str();
		for ( string::iterator it = n_str.begin(); it != n_str.end(); it++ )
		{
			char c = *it;
			if ( c >= '4' ) (*it)++;
			if ( c >= '5' ) (*it)++;
		}
		istringstream is( n_str );
		is >> n;
		cout << n << endl;
	}

	return 0;
}

Measured memory_bytes: 928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


int make_factorial(int num){
    int factorial = 1;
    for(int i=1;i<num+1;i++){
        factorial *= i;
    }
    return factorial;
}

vector<vector<int>> generate_permutation(vector<int> &v){
    sort(v.begin(), v.end());
    int factorial = make_factorial(v.size());
    int  cnt = 0;
    vector<vector<int>> permutation(factorial, vector<int>(v.size()));
    do{
        for(int i=0;i!=v.size();i++){
            permutation[cnt][i] = v[i];
        }
        cnt++;
    }while(next_permutation(v.begin(), v.end()));
    return permutation;
}


int main() {
    ll d, g;
    cin >> d >> g;
    vector<ll> p(d);
    vector<ll> c(d);
    for(int i = 0; i < d; i++){
        cin >> p[i] >> c[i];
    }

    vector<int> data(d);
    for(int i = 0; i < d; i++){
        data[i] = i;
    }
    vector<vector<int>> order = generate_permutation(data);

    ll ans = 999999999999999;
    for(int i = 0; i < order.size(); i++){
        ll tmp_num = 0;
        ll tmp_score = 0;
        for(int j = 0; j < d; j++){
            if(tmp_score + 100*(order[i][j]+1)*p[order[i][j]] + c[order[i][j]] >= g){
                int x = (g-tmp_score+100*(order[i][j]+1)-1)/(100*(order[i][j]+1));
                if(x<=p[order[i][j]]){tmp_num += x;}
                else{tmp_num += p[order[i][j]];}
                ans = min(ans, tmp_num);
                break;
            }else{
                tmp_num += p[order[i][j]];
                tmp_score += 100*(order[i][j]+1)*p[order[i][j]] + c[order[i][j]];
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 255360
s=input()
if s[0]==">":a=[0,1]
if s[0]=="<":a=[1]
for i in range(1,len(s)):
  if s[i-1]!=s[i]:a.append(1)
  else:a[-1]+=1
if len(a)%2:a.append(0)
ans=0
for i in range(len(a)//2):
  m=max(a[i*2],a[i*2+1])
  ans+=m*(m+1)//2
  m=min(a[i*2],a[i*2+1])
  ans+=m*(m-1)//2
print(ans)

Measured memory_bytes: 6300
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	int count = 0;
	if(a%2 || b%2 || c%2){
		cout << count << endl;
	}
	else if(a==b && a==c){
		count = -1;
		cout << count << endl;
	}
	else{
		while(1){
			if(a%2 || b%2 || c%2) break;
			int t1 = (b+c)/2;
			int t2 = (a+c)/2;
			int t3 = (a+b)/2;
			a = t1;
			b = t2;
			c = t3;
			count++;
		}
		cout << count << endl;
	}
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
static const double pi=3.14159265358979;
int main(){
double a,b,x;
  cin>>a>>b>>x;
  if((a*a*b)/2<=x){
  double ans=atan((2*(a*a*b-x))/(a*a*a));
  ans*=(180/pi);
  cout<<fixed<<setprecision(10)<<ans<<endl;
  }else{
  double ans=atan((a*b*b)/(2*x));
    ans*=(180/pi);
    cout<<fixed<<setprecision(10)<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 4120
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <bitset>
#include <iostream>

int n;
long long ans, m;
long long a[300000];

int main()
{
    ans = 10000000000000000;
    
    scanf("%d %lld", &n, &m);
    
    for (int i = 1; i <= n; ++i)
    {
        scanf("%lld", &a[i]);
        a[i] += a[i - 1];
    }
    
    long long temp;
    int p;
    long long cost, delta;
    for (int k = 1; k <= n; ++k)
    {
        temp = m * k + n * m;
        p = n;
        cost = 3;
        //printf("HERE");
        while (p > 0)
        {
            if (p - k < 0)
                delta = a[p];
            else delta = a[p] - a[p - k];
            temp += delta * cost;
            if (cost == 3) temp += 2 * delta;
            if (temp > ans) break;
            //printf("%I64d\n", temp);
            p -= k;
            cost += 2;
        }
        if (temp < ans) ans = temp;
    }
    printf("%lld\n", ans);
        
    return 0;
}

Measured memory_bytes: 1792
n, y = gets.strip.split.map(&:to_i)
_i, _j, _k = -1, -1, -1

(0..n).each do |i|
    (0..n-i).each do |j|
       if i * 10000 + j * 5000 + (n - i - j) * 1000 == y
           _i, _j, _k = i, j, n - i - j
       end
    end
end

puts "#{_i} #{_j} #{_k}"

Measured memory_bytes: 14400
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
int dp[5010][5010];

signed main(){
  int n,mod=1000000007;
  string s;
  cin>>n>>s;
  int m=s.size();
  dp[0][0]=1;
  rep(i,n){
    rep(j,5001){
	 dp[i+1][j+1]+=dp[i][j];
	 dp[i+1][j+1]%=mod;
	 if(j>0){
	   dp[i+1][j-1]+=dp[i][j]*2;
	   dp[i+1][j-1]%=mod;
	 }else{
	   dp[i+1][j]+=dp[i][j];
	   dp[i+1][j]%=mod;
	 }
    }
  }
  cout<<dp[n][m]<<endl;
  return 0;
}


Measured memory_bytes: 195968
#include <stdio.h>

int main(void){
    int n,i,max=0,sum=0;
    scanf("%d",&n);
    int p[n];
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
        if(p[i]>max) max=p[i];
        sum+=p[i];
    }
    printf("%d\n", sum-max/2);
    return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	weather := [4]string{"Sunny", "Cloudy", "Rainy", "Sunny"}

	for i:=0; i<len(weather)-1; i++{
		if s == weather[i]{
			fmt.Println(weather[i+1])
		}
	}
}

Measured memory_bytes: 1768
fn main() {
    let mut sc = Scanner::new();
    let d = sc.usize_read();
    let n = sc.usize_read();
    let c = match d {
        0 => 1,
        1 => 100,
        2 => 10000,
        _ => panic!(),
    };
    if n == 100 {
        println!("{}", 101 * c);
    } else {
        println!("{}", n * c);
    }
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;

namespace Kanazawa
{
    public static class Kaga
    {
        public static void Main()
        {
            var n = Cint();
            var a = Cint();
            var b = Cint();

            Cout(
                Enumerable.Range(1, n)
                    .Where(i =>
                    {
                        var s = i.ToString().ToCharArray().Select(f => int.Parse(f.ToString())).Sum();
                        return s >= a && s <= b;
                    })
                    .Sum()
            );
        }
        
        #region Input and Output

        private static readonly List<string> Buffer = new List<string>();

        private static string Cin()
        {
            ReadBuffer();

            var str = Buffer.First();
            Buffer.RemoveAt(0);

            return str;
        }

        private static IEnumerable<string> CinA() => Console.ReadLine()?.Split();
        private static int Cint() => int.Parse(Cin());
        private static int[] CintA() => CinA().Select(int.Parse).ToArray();
        private static void Cout(object obj) => Console.WriteLine(obj);

        private static void ReadBuffer()
        {
            if (Buffer.Any()) return;

            var line = Console.ReadLine();
            if (line != null && line.Contains(' '))
            {
                Buffer.AddRange(line.Split());
            }
            else
            {
                Buffer.Add(line);
            }
        }

        #endregion
        #region Loops

        private static void Loop(int count, Action<int> action) => Loop(0, count, action);
        private static void Loop(int init, int count, Action<int> action, int step = 1)
        {
            for (var i = init; i < count + init; i += step)
            {
                action(i);
            }
        }

        #endregion
    }
}


Measured memory_bytes: 15316
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<bitset>
using namespace std;


int v,es,st;
int ans=1<<21;
int t1,t2,t3;
const int inf = 1<<21;
int G[21][21];
int null=-1;
long long int dp[1<<15+1][21];



int rec(long long int s,int i){
    //cout << "hikisuu is s,i " << bitset<5>(s) << " " << i << endl;
    //cout << bitset<5>(s) << endl;
    if(s == (1<<v)-1 && i == st){
        //cout << "hekk" << endl;
        dp[s][i] = 0;
        return 0;
    }
    if(dp[s][i] != null) return dp[s][i];

    int res = inf;
    for(int j=0;j<v;j++){//j is last pushed to s - {i}
        
        if((s & (1<<j))) continue;
        if(res > rec(s|(1<<j),j)+G[i][j]){
            res = rec(s|(1<<j),j)+G[i][j];
            //cout << st << " " << bitset<6>(s) << " " << i << "->" << j << " " << res << endl; 
        }
    }
    dp[s][i] = res;
    //cout << "s and s_pre is " << bitset<5>(s) << " " << bitset<5>(s_pre) << " " << res << endl;
    //cout << j1 << "->" << i1 << " cost = " << G[j1][i1] << endl;
    //cout << res << endl;
    return res;
}

int main(){

    for(int i=0;i<21;i++){
        for(int j=0;j<21;j++){
            G[i][j] = inf;
        }
    }

    cin >> v >> es;
    for(int i=0;i<es;i++){
        cin >> t1 >> t2 >> t3;
        G[t1][t2] = t3;
    }

    for(int i=0;i<(1<<15) + 1;i++){
        for(int j=0;j<21;j++){
            dp[i][j] = null;
        }
    }
    for(int k=0;k<v;k++){
        st = k;
        ans = min(rec(0,k),ans);

        for(int i=0;i<(1<<15) + 1;i++){
            for(int j=0;j<21;j++){
                dp[i][j] = null;
            }
        }
    }

    if(ans!=inf){
        cout << ans << endl;
    }
    else cout << -1 << endl;
    return 0;

}


Measured memory_bytes: 8484
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	string S; cin >> S;
	if (S.size() == 2) cout << S << endl;
	else cout << S[2] << S[1] << S[0] << endl;
	
	return 0;
}



Measured memory_bytes: 256
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def eprint(s):
    if type(s) != type('str'):
        s=str(s)

    sys.stderr.write(s+'\n')
    return

def main():
    l, r = map(int, input().split())
    if l <= 2019 and 2019 <= r:
        print(0)
        return 
    if r-l >= 2019:
        print(0)
        return

    m = 10**9

    for i in range(l, r):
        for j in range(i+1,r+1):
            m = min(m, i*j % 2019)
    print(m)
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 64620
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc  = new Scanner(System.in);
    static final int     MOD = (int) 1E9 + 7;

    public static void main(String[] args) {
        int N = nint();
        String s = nstr();
        if (N % 2 == 1) {
            System.out.println("No");
            return;
        }
        
        System.out.println(s.substring(0, N/2).equals(s.substring(N/2)) ? "Yes" : "No");
    }
    private static int nint() {
        return sc.nextInt();
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static double ndouble() {
        return sc.nextDouble();
    }

    private static double[] ndoubles(int n) {
        return ndoubles(n, 0, 0);
    }

    private static double[] ndoubles(int n, int padL, int padR) {
        double[] d = new double[n + padL + padR];
        for (int i = 0; i < n; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0, 0);
    }

    private static char[][] nchars2(int h, int w, int padLU, int padRD) {
        char[][] a2 = new char[h + padLU + padRD][w + padLU + padRD];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, w);
        return a2;
    }

    private static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    private static int min(int... is) {
        return Arrays.stream(is).min().getAsInt();
    }

    private static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    private static int max(int... is) {
        return Arrays.stream(is).max().getAsInt();
    }

    private static long abs(long a, long b) {
        return Math.abs(a - b);
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define POWT(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

const pii four_Dir[4] = {
	{ 0,-1 },{ -1 ,0 },{ 0 ,1 },
	{ 1 ,0 }
};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}

signed main() {
	int n;
	scanf("%d", &n);
	vector<int> p(n);
	REP(i, n) {
		scanf("%d", &p[i]);
		p[i]--;
	}
	vector<int> ans(n);

	REP(i, n) {
		ans[i] = (n-i + 1)*n;
		printf("%d ", (i + 1)*n);
	}

	REP(i, n) {
		ans[p[i]] -= n-i-1;
	}
	printf("\n");
	REP(i, n) {
		printf("%d ", ans[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 768
/*      Abhijith    */
#include<bits/stdc++.h>
#include<iomanip>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
using namespace std;
void gcd_extended(lld a,lld b,lld *x,lld *y)
{
    if(a==0)
    {
        *x=0;
        *y=1;
        return;
    }
    lld x1,y1;
    gcd_extended(b%a,a,&x1,&y1);
    *x=y1-(b/a)*x1;
    *y=x1;
    return;
}
lld ncr(lld n,lld k)
{
    if (k > n) return 0LL;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;

    int result = n;
    for( int i = 2; i <= k; ++i ) {
        result = (result*(n-i+1))%mod;
    }
    for(int i=2;i<=k;i++)
    {
        lld x,y;
        gcd_extended(mod,i,&x,&y);
        y=(y%mod+mod)%mod;
        result=(result*y)%mod;
    }
    return result;
}
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
     lld n,m,k;
     lld inv=500000004;
     cin>>n>>m>>k;
     lld haha=0;
     lld vava=0;
     rep(i,0,n-1)
     {
         vava=(vava+((i*(i+1))/2+((n-1-i)*(n-i))/2))%mod;
     }
     rep(i,0,m-1)
     {
         haha=(haha+((i*(i+1))/2+((m-i-1)*(m-i))/2))%mod;
     }
     lld yo=((n*(n))*haha+(m*(m))*vava)%mod;
     yo=(yo*inv)%mod;
     lld ans=(ncr(n*m-2,k-2)*yo)%mod;
     cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	private static HashSet<String> set;
	private static String s;

	private static int check(String cat){
		if(set.contains(cat)) return 0;

		for(int k=0;k<2;k++){
			for(int j=0;j<4;j++){
				//4ツ嘉ア2ツ古つつクツづァツつオ
				for(int i=0;i<4;i++){
					set.add(cat);
					set.add(cat=cat.substring(2)+cat.substring(0,2));
				}

				cat = "" +
					cat.charAt(1) + cat.charAt(3) +
					cat.charAt(0) + cat.charAt(2) +
					cat.charAt(6) + cat.charAt(4) +
					cat.charAt(7) + cat.charAt(5);
			}

			cat = "" +
				cat.charAt(1) + cat.charAt(7) +
				cat.charAt(3) + cat.charAt(5) +
				cat.charAt(2) + cat.charAt(4) +
				cat.charAt(0) + cat.charAt(6);
		}

		return 1;
	}

	private static int solve(int rem,String cat,boolean used[]){
		if(rem == 0){
			return check(cat);
		}

		int res = 0;
		for(int i=0;i<8;i++){
			if(!used[i]){
				used[i] = true;
				res += solve(rem-1,cat+s.charAt(i),used);
				used[i] = false;
			}
		}
		return res;
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()){
			s = "";
			HashMap<String,Integer> map = new HashMap<String,Integer>();
			for(int i=0;i<8;i++){
				String tmp = sc.next();
				if(!map.containsKey(tmp)){
					map.put(tmp,i);
					s += i;
				}
				else{
					s += map.get(tmp);
				}
			}

			set = new HashSet<String>();
			boolean[] used = new boolean[8];
			System.out.println(solve(8,"",used));
		}
	}
}

Measured memory_bytes: 18000
!--Greedy Takahashi
program cookie
  implicit none

  integer(8) :: i, j
  integer(8) :: A, B, K, AA, BB

read *, A, B, K

if (A >= K) then
  print *, A-K, B
  stop
else if (A < K) then
  AA = 0
  BB = B-(K-A)
  if (BB >= 0) then
    BB = BB
  else
    BB = 0
  end if

  print *, AA, BB
endif

end program cookie



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MaxN = 400000;
int n, a[MaxN + 5], nxt[MaxN + 5];
int x[MaxN + 5], y[MaxN + 5], re[MaxN + 5];
bool flag[MaxN +5];
map <int, int> H;
struct ARR {
	int w, l, r, ty;
}b[MaxN + 5];
vector <int> v[MaxN + 5];

bool cmp(ARR A, ARR B) {
	return A.w <  B.w;
}

void Init()
{
	int tot = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &x[i], &y[i]);
		a[++tot] = x[i]; a[++tot] = y[i];
	}
	sort(a + 1, a + 2 * n + 1);
	a[0] = -1; int cnt = 0;
	for (int i = 1; i <= 2 * n; i++) {
		if (a[i] != a[i - 1]) cnt++;
		H[a[i]] = cnt;
		re[cnt] = a[i];
	}
	tot = 0;
	for (int i = 1; i <= n; i++) {
		x[i] = H[x[i]]; y[i] = H[y[i]];	
		if (x[i] > y[i]) swap(x[i], y[i]);
		b[++tot].w = x[i]; b[tot].ty = 0; b[tot].r = y[i];
		b[++tot].w = y[i]; b[tot].ty = 1; b[tot].l = x[i];
	}	
	sort(b + 1, b + tot + 1, cmp);
	/*for (int i = 1; i <= tot; i++) 
		printf("%d %d %d\n", re[b[i].w], b[i].ty, b[i].r);*/
}

void Solve()
{
	n = 2 * n;
	for (int i = 1; i <= n; i++) 
		if (b[i].ty == 1) v[b[i].w].push_back(i);
	for (int i = 1; i <= n; i++) {
		if (b[i].ty == 0) {
			nxt[i] = v[b[i].r][v[b[i].r].size() - 1];
			v[b[i].r].pop_back();
		}
	}
	//for (int i = 1; i <= n; i++) printf("%d ", nxt[i]); printf("\n");
	int cnt =  0, Rmin = 1 << 30, Rmax = 0, Bmin = 1 << 30, Bmax = 0;
	memset(flag, 0, sizeof(flag));
	for (int i = 1; i <= n; i++) {
		if (flag[i]) Rmin = min(Rmin, re[b[i].w]), Rmax = max(Rmax, re[b[i].w]);
		else {
			Bmin = min(Bmin, re[b[i].w]), Bmax = max(Bmax, re[b[i].w]);
			flag[nxt[i]] = true;
		}
		//printf("%d %d %d %d\n", Rmin, Rmax, Bmin, Bmax);
	}
	LL ans = ((LL)Rmax - Rmin) * (Bmax - Bmin);
	memset(flag, 0, sizeof(flag));
	int pos = n;
	for (int i = n; i >= 1; i--)
		if (nxt[i] != 0) {pos = i; break;}
	LL temp = re[b[n].w] - re[b[1].w];
	int MaX = 0;
	for (int i = 1; i <= n; i++) {
		if (flag[i - 1]) break;	
		else {
			flag[nxt[i]] = true;
			ans = min(ans, (re[b[max(MaX, pos)].w] - re[b[i].w]) * (LL)temp);
			MaX = max(MaX, nxt[i]);
		}
	}
	printf("%lld\n", ans);
}

int main()
{
	while (~scanf("%d", &n)) {
		Init();
		Solve();
	}
	return 0;
}

Measured memory_bytes: 49024
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   int a=kbd.nextInt();
   int b=0;
   if(400<=a&&a<=599){
     b=8;
   }
   if(600<=a&&a<=799){
     b=7;
   }
   if(800<=a&&a<=999){
     b=6;
   }
   if(1000<=a&&a<=1199){
     b=5;
   }
   if(1200<=a&&a<=1399){
     b=4;
   }
   if(1400<=a&&a<=1599){
     b=3;
   }
   if(1600<=a&&a<=1799){
        b=2;
      }
      if(1800<=a&&a<=1999){
        b=1;
      }
      System.out.println(b);
    }
  }


Measured memory_bytes: 35692
use std::io::*;
use std::str::FromStr;

const MOD: i64 = 1000000007;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn modpow(x: i64, y: i64) -> i64 {
    let mut res: i64 = 1;
    for _i in 0..y {
        res = res * x % MOD;
    }
    return res;
}

fn main() {
    let n: i64 = read();
    let ans1 = modpow(10, n);
    let ans2 = modpow(9, n);
    let ans3 = modpow(8, n);
    let mut ansm = (ans1 - ans2 - ans2 + ans3) % MOD;
    ansm = (ansm + MOD) % MOD;
    println!("{}", ansm);
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>

template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

using lint = long long;
constexpr lint INF = 1LL << 60;

void solve() {
    int n, m, k, s;
    std::cin >> n >> m >> k >> s;
    lint p, q;
    std::cin >> p >> q;

    std::vector<bool> out(n, false), danger(n, false);
    std::queue<std::pair<int, int>> que;
    while (k--) {
        int v;
        std::cin >> v;
        --v;
        que.emplace(v, 0);
        out[v] = true;
        danger[v] = true;
    }

    std::vector<std::vector<int>> graph(n);
    while (m--) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    while (!que.empty()) {
        int v, d;
        std::tie(v, d) = que.front();
        que.pop();
        if (d == s) continue;

        for (auto u : graph[v]) {
            if (danger[u]) continue;
            danger[u] = true;
            que.emplace(u, d + 1);
        }
    }

    std::vector<lint> dist(n, INF);
    dist[0] = 0;
    MinHeap<std::pair<lint, int>> heap;
    heap.emplace(0, 0);

    while (!heap.empty()) {
        lint d;
        int v;
        std::tie(d, v) = heap.top();
        heap.pop();
        if (dist[v] < d) continue;

        for (int u : graph[v]) {
            if (out[u]) continue;

            lint nd = dist[v] + (u == n - 1 ? 0 : danger[u] ? q : p);
            if (nd >= dist[u]) continue;

            dist[u] = nd;
            heap.emplace(nd, u);
        }
    }

    std::cout << dist.back() << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}



Measured memory_bytes: 10380
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <string>

using namespace std;

int main()
{
  string s[1001], ms, fs, ss;
  int m = 0, c, i = 0;
  getline(cin, ss);
  stringstream gs(ss);
  while(gs >> s[i]){
    if(s[i].size() > m){
      m = s[i].size();
      ms = s[i];
    }
    i++;
  }
  for(i = 0, c = 0; i < 1001; i++){
    for(int j = i + 1; j < 1001; j++){
      if(s[i].compare(s[j]) == 0){
	int nc = 0;
	nc++;
	if(nc > c){
	  c = nc;
	  fs = s[i];
	}
      }
    }
  }
  cout << fs << " " << ms << endl;
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#define MAX_N 10005

using namespace std;

typedef pair<int, int> P;
struct edge {
  int u, v;
  double cost;
  edge() {}
  edge(int U, int V, double C): u(U), v(V), cost(C) {}
};
vector<edge> G;
P cord[MAX_N];
int par[MAX_N];
int N, M;

bool compare(edge a, edge b) {
  return a.cost < b.cost;
}
void init() {
  for (int i = 1; i <= N; i++) par[i] = i;
}
int find(int x) {
  if (par[x] == x) return x;
  else return par[x] = find(par[x]);
}
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  par[x] = y;
}
bool same(int x, int y) {
  return find(x) == find(y);
}
double get_dis(P a, P b) {
  return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}
double kruscal() {
  init();
  sort(G.begin(), G.end(), compare);
  double res = 0.0;
  for (int i = 0; i < G.size(); i++) {
    edge e = G[i];
    if (!same(e.u, e.v)) {
      res += e.cost;
      unite(e.u, e.v);
    }
  }
  return res;
}
int main() {
  scanf("%d%d", &N, &M);
  double total_cost = 0.0;
  for (int i = 1; i <= N; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    cord[i] = make_pair(x, y);
  }
  for (int i = 0; i < M; i++) {
    int p, q;
    scanf("%d%d", &p, &q);
    double d = get_dis(cord[p], cord[q]);
    total_cost += d;
    G.push_back(edge(p, q, -d));
  }
  printf("%.3lf\n", total_cost + kruscal());
  return 0;
}



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

int main()
{
	int N, H, W;
	cin >> N;
	while (N--) {
		cin >> H >> W;
		vector<int> used(26), xma(26), xmi(26, 100), yma(26), ymi(26, 100);
		vector<vector<char>> a(H, vector<char>(W));
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >> a[i][j];
				if (a[i][j] != '.') {
					int p = a[i][j] - 'A';
					used[p] = 1;
					xma[p] = max(xma[p], i);
					xmi[p] = min(xmi[p], i);
					yma[p] = max(yma[p], j);
					ymi[p] = min(ymi[p], j);
				}
			}
		}
		vector<vector<int>> d(26, vector<int>(26, 1000));
		for (int i = 0; i < 26; i++) {
			d[i][i] = 0;
		}
		bool sus = false;
		for (int i = 0; i < 26; i++) {
			if (used[i]) {
				for (int x = xmi[i]; x <= xma[i]; x++) {
					for (int y = ymi[i]; y <= yma[i]; y++) {
						if (a[x][y] == '.') {
							sus = true;
						}
						else if (a[x][y] - 'A' != i) {
							d[i][a[x][y] - 'A'] = -1;
						}
					}
				}
			}
		}
		for (int k = 0; k < 26; k++) {
			for (int i = 0; i < 26; i++) {
				for (int j = 0; j < 26; j++) {
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
		for (int i = 0; i < 26; i++) {
			if (d[i][i] < 0) {
				sus = true;
				break;
			}
		}
		cout << (sus ? "SUSPICIOUS" : "SAFE") << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#include<iostream>

using namespace std;

int fib(int n);

int memo[1000];

int main() {
  int n;

  //入力
  cin >> n;

  //出力
  cout << fib(n) << endl;

  return 0;
}

int fib(int n){

  if(n==0 || n == 1){
    return 1;
  }else if(memo[n] != 0){
    return memo[n];
  }else{
    return memo[n] = fib(n-1) + fib(n-2);
  }
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
inline void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
inline void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}
const int N = 2e5 + 5;
int a[N], n;
long long k;
inline bool check(int x) {
	long long cnt = 0;
	for (int i = 1; i <= n; i ++) {
		cnt += 1ll * (a[i] - 1) / x;
	}
	return cnt <= k;
}
int main() {
	readin(n); readin(k);
	for (int i = 1; i <= n; i ++) {
		readin(a[i]);
	}
	int l = 1, r = 1e9, ans = 1e9;
	while(l <= r) {
		int mid = l + r >> 1;
		if (check(mid)) {
			ans = mid;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	writeln(ans, '\n');
	return 0;
}




Measured memory_bytes: 4396
#include<stdio.h>

int main(void){
	int i, j;
	int num;
	int mini, max;
	unsigned long int sum;
	int array[10000];

	scanf("%d", &num);

	for(i = 0; i < num; i++){
		scanf("%d", &array[i]);
	}

	mini = array[0];
	max = array[0];
	sum = 0;

	for(j = 0; j < num; j++){
		if(mini > array[j]){
			mini = array[j];
		}

		if(max < array[j]){
			max = array[j];
		}

		sum = sum + array[j];
	}

	printf("%d %d %ld\n", mini, max, sum);

	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	vector<pii> a(m);
	rep(i, m) cin >>a[i].first >> a[i].second;
	stable_sort(all(a), [](auto& l, auto& r){return l.second < r.second;});
	int ans =0, cr = 0;
	rep(i, m) if(cr <= a[i].first){
		ans++; cr = a[i].second;
	}
	cout <<ans <<"\n";
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
void maxHeapify(int *,int);

int H;

int main(){
  int i;
  int *heap;
  scanf("%d",&H);
  heap=(int *)malloc(H*sizeof(int));
  for(i=1;i<=H;i++) scanf("%d",&heap[i]);
  
  for(i=H/2;i>=1;i--)maxHeapify(heap,i);

  for(i=1;i<=H;i++) printf(" %d",heap[i]);
  printf("\n");
  free(heap);
  return 0;
}

void maxHeapify(int *A,int i){
  int r,l,largest,w;
  l=2*i;
  r=2*i+1;
  
  if(l<=H && A[l]>A[i]) largest=l;
  else largest=i;

  if(r<=H && A[r]>A[largest]) largest=r;

  if (largest!=i){
    w=A[i];
    A[i]=A[largest];
    A[largest]=w;
    maxHeapify(A,largest);
  }
  
}



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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	map<int, int> cnt;
	for(int i=0; i<n; i++){
		int a;
		cin >> a;
		cnt[a]++;
	}
	int m=n;
	for(int i=n-1; i>0; i--){
		if(cnt[i]!=0){
			m=i;
			break;
		}
	}

	bool flg=true;
	for(int i=m; i>m/2+1; i--){
		flg&=(cnt[i]>=2);
	}
	for(int i=1; i<m/2; i++){
		flg&=(cnt[i]==0);
	}
	if(m%2==0){
		flg&=(cnt[m/2]==1)&(cnt[m/2+1]>=2);
	}else{
		flg&=(cnt[m/2]==0)&(cnt[m/2+1]==2);
	}

	if(flg) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int m,n,i,j,a[100][100],b[100],c[100];
  scanf("%d %d",&n,&m);
  for(i=0; i<n; i++){
    for(j=0; j<m; j++){
      scanf("%d ",&a[i][j]);
    }   
  }
  for(j=0; j<m; j++){
    scanf("%d",&b[j]);
  }
  for(i=0; i<n; i++){
    c[i]=0;
  }
  for(i=0; i<n; i++){
    for(j=0; j<m; j++){
      c[i]+=(a[i][j]*b[j]);
    }
  }//-----                          
 for(i=0; i<n; i++){
    printf("%d\n",c[i]);
  }
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define Forr(i, s, e) for (ll i = s; i > e; i--)
#define pb push_back
#define ll long long
#define int ll
#define mp make_pair

signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(8);
    double d, t, s;
    cin >> d >> t >> s;
    if ((d / s) <= t)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3732
using System;
using System.Text;

namespace _0005 {

	public static class Program {

		public static void Main() {
			var week = int.Parse(Console.ReadLine());
			var money = 100000d;
			for (int i = 0; i < week; i++) {
				money *= 1.05;

				int x = (int) (money % 1000);
				if (x > 0) {
					money = money - x + 1000;
				}
			}
			Console.WriteLine(money);
		}

	}

}

Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,c;
  cin>>n>>c;
  Int s=0;
  for(Int i=0;i<c;i++){
    Int p;
    cin>>p;
    s+=p;
  }
  cout<<(s+n)/(n+1)<<endl;
  return 0;
}



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

int main() {
  int N;
  cin >> N;
  
  int X = 0;
  int T = 100000000;
  int T2;
  int A = N;
  
  for (int i=0; i<8; i++) {
    
    T /= 10;
    
    X += N/T;
    T2 = N/T;
    N -= T2*T;
  }
  
  if (A%X == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256