akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define li long
#define pb push_back
#define mem(arr,x) memset(arr,x,sizeof(arr))

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j;
    cin>>n;
    ll a[n+1][4];
    for(i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    ll dp[n+1][4];
    mem(dp,0);
    for(j=0;j<3;j++)
    dp[0][j]=a[0][j];
    for(i=1;i<n;i++)
    {
      dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
      dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
      dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    ll ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 9828
<?php
// Your code here!
// fscanf(STDIN,"%d %d",$a,$b);
$n = trim(fgets(STDIN));
$m = ($n / 3600) - intval($n / 3600);
$s = $m * 60 - intval($m * 60);
echo intval($n / 3600) , ":", intval($m * 60), ":", round($s * 60);
?>



Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
    ll N, K;
    cin>>N>>K;
    vector<ll> P(N);
    rep(i, N){
        cin>>P[i];
    }
    sort(ALL(P));
    ll Ans=0;
    rep(i, K){
        Ans+=P[i];
    }
    cout<<Ans<<endl;
}
     

Measured memory_bytes: 3624
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <vector>
#include <unordered_map>
using namespace std;

struct node_t {
	string name;
	unordered_map<string, unique_ptr<node_t>> children;

	bool is_leaf() const {
		return children.size() == 0;
	}

	void add_child(const string &key, unique_ptr<node_t> &&p) {
		children[key] = move(p);
	}

	string find(const vector<string>& query, int depth = 0) const {
		if(depth == query.size()) return is_leaf() ? "string \"" + name + "\"" : "object";
		if(children.count(query[depth])) return children.at(query[depth])->find(query, depth + 1);
		return "no such property";
	}

	string to_string() const {
		if(is_leaf()) return name;
		string res = " ";
		for(const auto &e : children) {
			res += e.first + "(" + e.second->to_string() + ") ";
		}
		return res;
	}
};

vector<string> split(string s, const string &delim) {
	vector<string> res;
	int pos;
	while((pos = s.find(delim)) != string::npos) {
		if(pos) res.emplace_back(s.substr(0, pos));
		s = s.substr(pos + 1);
	}
	if(s.size()) res.emplace_back(s);
	return res;
}

int indent(const string &s) {
	for(unsigned i = 0; i < s.size(); ++i) {
		if(s[i] != ' ') return i;
	}
	return 0;
}

unique_ptr<node_t> mapping(const vector<string> &input, int &idx, int ind) {
	unique_ptr<node_t> res(new node_t);
	while(idx < input.size()) {
		if(indent(input[idx]) < ind) break;

		const int pos = input[idx].find(':');
		string property = input[idx].substr(ind, pos - ind);

		if(pos + 1 == input[idx].size()) {
			++idx;
			res->add_child(property, mapping(input, idx, indent(input[idx])));
		}
		else {
			unique_ptr<node_t> child(new node_t);
			child->name = input[idx++].substr(pos + 2);
			res->add_child(property, move(child));
		}
	}
	return res;
}

unique_ptr<node_t> parse(const vector<string> &input) {
	int idx = 0;
	return mapping(input, idx, 0);
}

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

	string query;
	getline(cin, query);

	vector<string> input;
	string line;
	while(getline(cin, line)) {
		input.emplace_back(line);
	}

	const auto root = parse(input);
	cout << root->find(split(query, ".")) << endl;

	return EXIT_SUCCESS;
}

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

namespace AtCoderCs
{

    class Program
    {

        const int Mod = 1000000007;

        static void Main()
        {

            var arg = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var list = new bool[arg[0]];
            for (int i = 0; i < arg[0]; i++) list[i] = false;

            for (int i = 0; i < arg[1]; i++)
            {

                var num = int.Parse(Console.ReadLine());
                var data = Console.ReadLine().Split(' ').Select(x => int.Parse(x));

                foreach (var info in data) list[info - 1] = true;

            }

            Console.WriteLine(list.Count(x => !x));

        }



    }
}


Measured memory_bytes: 28468
#include <stdio.h>
#include <string.h>

int main() {
    int N;
    scanf("%d", &N);
    char s[N][11];
    char dic[100][11];
    int dic_value[100];
    int i;
    for(i=0; i<N; i++) {
        scanf("%s", s[i]);
    }

    int M;
    scanf("%d", &M);
    char t[M][11];
    for(i=0; i<M; i++) {
        scanf("%s", t[i]);
    }


    int count;
    int max=0;
    int j;
    for(i=0; i<N; i++) {
        count = 0;
        for(j=0; j<=101; j++) {
            if(j<N) {
                if(strcmp(s[i], s[j])==0) {
                    count += 1;
                }
            }
            if(j<M) {
                if(strcmp(s[i], t[j])==0) {
                    count -= 1;
                }
            }
            if((j>=N) && (j>=M)) {
                break;
            }
        }
        if(max<count) {
            max = count;
        }
    }

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


    return 0;
    
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const char s[2]={'A','B'};
int a,b,c,d,q,k,nb;ll lim;
int calc(int x)
{
	return (a-(b-x+k-1)/k)/k;
}
inline int find(){
    R int l=0,r=b,mid,ans=0;
    while(l<=r){
        mid=(l+r)>>1;
        mid<=calc(mid)?(ans=mid,l=mid+1):r=mid-1;
    }
    return ans;
}
int main(){
//  freopen("testdata.in","r",stdin);
    for(scanf("%d",&q);q;--q){
        scanf("%d%d%d%d",&a,&b,&c,&d),--c;
		k=(max(a,b)+min(a,b))/(min(a,b)+1);
        if(k==1)fp(i,c,d-1)putchar(s[(i+(b>a))&1]);
        else{
            nb=find();
//          printf("qwq %d %d %d %d\n",a,b,k,nb);
            lim=nb+a-(b-nb+k-1)/k+1;
            fp(i,c,d-1)putchar(i<lim?s[i%(k+1)==k]:s[(a+b-i)%(k+1)>0]);
        }
        putchar('\n');
    }
    return 0;
}

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

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

  int n;
  cin >> n;

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

  bool flag = true;
  if(a[0] != 0) flag = false;

  long long answer = 0;
  for (int i = 1; i < n; i++) {
    if(a[i] > a[i - 1] + 1) {
      flag = false;
      break;
    }

    if(a[i] <= a[i - 1]) {
      if(a[i] == 0) continue;
      answer += (a[i] - 1);
    }
    answer++;
  }

  if(!flag) answer = -1;
  cout << answer << '\n';

  return 0;
}


Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int count = 10;
    int t = b;
    while(t/10 != 0){
        t /= 10;
        count *= 10;
    }
    double ans = sqrt(a*count+b);
    if(ceil(ans) != floor(ans))
        cout << "No";
    else
        cout <<"Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int h, n, sum, a;
    cin >> h >> n;
    sum = 0;
    rep(i, 0, n) {
        cin >> a;
        sum += a;
    }

    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]
if m > 0:
    s,c = zip(*sc)

arr = [0 for i in range(n)]

for i in range(m):
    if arr[s[i]-1] != 0 and arr[s[i]-1] != c[i]:
        print(-1)
        exit()
    if n != 1 and s[i]-1 == 0 and c[i] == 0:
        print(-1)
        exit()
    else:
        arr[s[i]-1] = c[i]

if n == 1 and arr[0] == 0:
    print(0)
    exit()

if arr[0] == 0:
    arr[0] = 1

print("".join(map(str,arr)))

Measured memory_bytes: 3064
N = int(input())
S = input().split()
X = 0

S1 = list(S[0])


S1_mod = [1 if i == "I" else i for i in S1]
S1_mod = [-1 if i == "D" else i for i in S1_mod]

l = []
for i in S1_mod:
  if i == -1:
    X += -1
    l.append(X)
  else:
    X+= 1
    l.append(X)


if max(l) < 0:
  print(0)
else:
  print(max(l))

Measured memory_bytes: 3064
#include <iostream>
#include <numeric>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	int  X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	int mmmax = 0;

	vector<int> p(A);
	vector<int> q(B);
	vector<int> r(C);
	vector<int> mix(X + Y + C);

	rep(i, A) {
		cin >> p.at(i);
	}
	rep(i, B) {
		cin >> q.at(i);
	}
	rep(i, C) {
		cin >> r.at(i);
	}
	sort(p.begin(), p.end());
	reverse(p.begin(), p.end());
	sort(q.begin(), q.end());
	reverse(q.begin(), q.end());
	rep(i, X) {
		mix.at(i) = p.at(i);
	}
	rep(i, Y) {
		mix.at(i + X) = q.at(i);
	}
	rep(i, C) {
		mix.at(i + X + Y) = r.at(i);
	}
	sort(mix.begin(), mix.end());
	reverse(mix.begin(), mix.end());

	long long wa = 0;
	rep(i, X + Y) {
		wa += mix.at(i);
	}
cout<<wa<<endl;
}

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

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

int main(void){
    int N,M;
    cin >> N >> M;
    int L[100000];
    int R[100000];
    rep(i,M){
        cin >> L[i] >> R[i];
    }
    int min,max;
    min = L[0];
    max = R[0];
    rep(i,M){
        if (L[i] > min) min = L[i];
        if (R[i] < max) max = R[i];
    }
    //cout << max << endl;
    //cout << min << endl;
    if (max >= min) cout << max - min + 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = n * 800;
		int y = n >= 15 ? (n / 15) * 200 : 0;
		System.out.println(x - y);
		sc.close();
	}
}

Measured memory_bytes: 22608
#include <stdio.h>
main(){
  int n,i,j,a[1000000],k;
  while(scanf("%d",&n) !=EOF){
    int c=0;
    for(i=2;i<=n;i++){
      a[i]=1;
    }
    for(i=2;i*i<=n;i++){
      if(a[i]==1){
	k=2;
	j=i*2;
	while(j<=n){
	  a[j]=0;
	  k++;
	  j=i*k;
	}
      }
    }
    for(i=2;i<=n;i++){
      if(a[i]==1) c++;
    }
    printf("%d\n",c);
  }
  return 0; 
}

Measured memory_bytes: 4316
toInt :: String -> Int
toInt = read :: String -> Int

lucas :: [Int]
lucas = 2 : 1 : zipWith (+) lucas (tail lucas)

isGoodNumber :: Int -> Bool
isGoodNumber n = mod (div n 10) 111 == 0 || mod (mod n 1000) 111 == 0 

main = do
  n <- toInt <$> getLine
  putStrLn $ if isGoodNumber n then "Yes" else "No"


Measured memory_bytes: 508
import sys
input=sys.stdin.readline #文字列入力はするな！！
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]*=-1
a=sorted(a)
for i in range(m):
    h=-heapq.heappop(a)
    h=h//2
    heapq.heappush(a,-h)
print(-sum(a))



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

string s;
vector<long long> v;

void solve();

int main() {
  solve();
  return 0;
}

void solve() {
  while(cin >> s) {
    int ssize = s.size();
    long long num = 0;
    if(s == "+") {
      num = v.back();
      v.pop_back();
      num += v.back();
      v.pop_back();
      v.push_back(num);
    }
    else if(s == "-") {
      num = v.back();
      v.pop_back();
      num = v.back() - num;
      v.pop_back();
      v.push_back(num);
    }

    else if(s == "*") {
      num = v.back();
      v.pop_back();
      num *= v.back();
      v.pop_back();
      v.push_back(num);
    }
    else {
      for(int i = 0; i < ssize; ++i) {
        num *= 10;
        num += s[i] - '0';
      }
      v.push_back(num);
    }
  }
  cout << v[0] << endl;
}


Measured memory_bytes: 3164
#include<cstdio>
using namespace std;
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    int x=(b-2*a)/2;
    int y=(4*a-b)/2;
    if((x+y==a)&&(4*x+2*y==b)&&(x>=0)&&(y>=0))
    {
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}



Measured memory_bytes: 3232
#include <iostream>

using namespace std;

int main()
{
	int n;
	int a, b, c;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c;
		if ( (a * a == b * b + c * c) || (b * b == c * c + a * a) || (c * c == a * a + b * b) ) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

int main(int argc, char const *argv[])
{
	int a[9];
	for (int i = 0; i < 9; ++i)
	{
		cin>>a[i];
	}
	int n;
	cin>>n;
	int b,c[9]={};
	for (int i = 0; i < n; ++i)
	{
		cin>>b;
		for (int j = 0; j < 9; ++j)
		{
			if (a[j]==b)
			{
				c[j]=1;
			}
		}
	}
	int f=0;
	for (int i = 0; i < 3; ++i)
	{
		if (c[0+i*3]==1&&c[1+i*3]==1&&c[2+i*3]==1)
		{
			f=1;
		}
		if (c[0+i]==1&&c[3+i]==1&&c[6+i]==1)
		{
			f=1;
		}
	}
	if (c[0]==1&&c[4]==1&&c[8]==1)
	{
		f=1;
	}
	if (c[2]==1&&c[4]==1&&c[6]==1)
	{
		f=1;
	}
	if (f==1)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 256
let id x = x
let n = Scanf.scanf "%d\n" id
let ar = Array.init n (fun _ -> Scanf.scanf "%d " id)

let rec solve i sum ans =
  if i >= n then ans
  else
    let pre = sum and sum' = sum + ar.(i) in
    if pre * sum' < 0 then solve (succ i) sum' ans
    else solve (succ i) (if pre < 0 then 1 else -1) (ans + (abs sum') + 1)


let () =
  (match ar.(0) with
   | 0 -> min (solve 1 1 1) (solve 1 (-1) 1)
   | a -> min (solve 1 a 0) (solve 1 (if a < 0 then 1 else -1) (abs a + 1)))
  |> Printf.printf "%d\n"

Measured memory_bytes: 5376
#include<iostream>

using namespace std;

int main() {
	long long x, a, b;
	cin >> x >> a >> b;
	if (a >= b) cout << "delicious" << endl;
	else {
		if (b <= a + x)cout << "safe" << endl;
		else cout << "dangerous" << endl;
	}
	return 0;
}

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

def judge(a: int, b: int, n: int) -> int:
    if b < a:
        return 0
    elif n == 1 and a != b:
        return 0
    elif n == 1:
        return 1
    else:
        return (b * (n-1) + a) - (a * (n-1) + b) + 1
    
print(judge(a,b,n))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n, s, a[N], b[N];
int main()
{
    ll i, num, t;
//    freopen ("input.txt", "r", stdin);
    cin >> n;
    for (i = 0; i < n; i++) {
        scanf ("%lld %lld", &a[i], &b[i]);
    }
    s = 0;
    for (i = n - 1; i >= 0; i--) {
        if (b[i] > 1) {
//            num = (a[i] + s) % b[i];
//            num = (b[i] - num) % b[i];
            t = (a[i] + s) / b[i];
            if ((a[i] + s) % b[i] > 0) t++;
            num = b[i] * t - (a[i] + s);
        } else {
//            if (a[i] + s > 0) num = 0;
//            else num = 1;
            num = 0;
        }
        s += num;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 1920
k, n = list(map(int, input().split()))
arr = list(map(int, input().split()))
mx = 0
for i in range(n - 1):
    mx = max(mx, abs(arr[i] - arr[(i + 1) % n]))
mx = max(mx, k - arr[n - 1] + arr[0])
print(k - mx)

Measured memory_bytes: 26444
#include <algorithm>
#include <iostream>
#include <vector>
#include <tuple>
#include <set>

using namespace std;
using ll = long long;


int main() {

    ll N, Q;
    cin >> N >> Q;

    vector< tuple<ll,ll,ll> > A(N);
    vector<ll> ans(Q, -1);

    for(ll i=0, s, t, x; i<N; i++) {
        cin >> s >> t >> x;
        A[i]={x, s, t};
    }

    sort(A.begin(), A.end());

    set< pair<ll, ll> > P;

    for(ll i=0, d; i<Q; i++) {
        cin >> d;
        P.insert({d, i});
    }

    for(int i=0; i<N; i++)
    {
        auto &[x, s, t] = A[i];
        int j=0;

        pair<int, int> l = {s-x, -1};
        pair<int, int> r = {t-x, -1};

        // range of people that will stops at [l, r)
        auto L = P.lower_bound(l);
        auto R = P.lower_bound(r);

        vector< pair<int, int> > K;

        while(L != R) {

            j = (*L).second;
            ans[j] = x;

            // marking this person to remove later
            K.push_back(*L);
            L++;
        }

        for(int i=0; i<K.size(); i++) {
            P.erase(K[i]);
        }
    }

    for(int i=0; i<Q; i++) {
        cout << ans[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 24008
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
char s[100005];
int f[100005],nxt[100005][3],v[100005],db[100005];
inline void add(int &x,int y){
	x+=y;
	if(x>=mod)x-=mod;
}
int main(){
	scanf("%s",s+1);
	int l=strlen(s+1);
	for(int i=1;i<=l;i++)v[i]=(v[i-1]+s[i]-'a'+1)%3;
	for(int i=l;i>=1;i--){
		for(int j=0;j<3;j++)nxt[i][j]=nxt[i+1][j];
		nxt[i][v[i]]=i;
		db[i]=s[i]==s[i+1]?i+1:db[i+1];
	}
	if(!db[1]){puts("1"); return 0;}
	f[0]=1;
	for(int i=0;i<l;i++){
		for(int j=1;j<=2;j++){
			if(s[i+1]-'a'+1==j)add(f[i+1],f[i]);
			else if(db[i+1]&&nxt[db[i+1]][(v[i]+j)%3])add(f[nxt[db[i+1]][(v[i]+j)%3]],f[i]);
		}
	}
	int ans=0;
	for(int i=1;i<=l;i++)if(v[i]==v[l])add(ans,f[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;

void dfs(int p, int vmin, int vmax, vector<vector<pair<int,int> > > &adj, vector<bool> &used){
    if(used[p]) return;
    used[p] = true;
    for(int i=0; i<(int)adj[p].size(); i++){
        if(vmin <= adj[p][i].second && adj[p][i].second <= vmax){
            dfs(adj[p][i].first, vmin, vmax, adj, used);
        }
    }
}

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n==0) break;

        vector<vector<pair<int,int> > > adj(n);
        set<int> weight;
        for(int i=0; i<m; i++){
            int a,b,w;
            cin >> a >> b >> w;
            a--; b--;
            adj[a].push_back(make_pair(b,w));
            adj[b].push_back(make_pair(a,w));
            weight.insert(w);
        }

        int s=0, e=10000;
        while(s<e){
            int mid=(s+e)/2;
            bool success=false;
            for(set<int>::iterator itr=weight.begin(); itr!=weight.end(); itr++){
                vector<bool> used(n, false);
                dfs(0, *itr, *itr+mid, adj, used);
                bool flag=true;
                for(int i=0; i<n; i++){
                    if(!used[i]){
                        flag = false;
                        break;
                    }
                }
                if(flag){
                    success=true;
                    break;
                }
            }
            if(success) e=mid;
            else s=mid+1;
        }

        if(e==10000){
            cout << -1 << endl;
        }else{
            cout << s << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3388
# 最大公約数を求める
def gcm(m, n):
    # mを小さくする
    if m > n:
        _temp = n
        n = m
        m = _temp

    while m != 0:
        #print("{}, {}".format(m, n))
        m, n = n % m, m

    return n

a, b, = map(int, input().split())
g = gcm(a, b)

print("{}".format((int)(a * b / g)))

Measured memory_bytes: 9080
#include <stdio.h>
#include <string.h>

int main(void){
    int K;
    char S[100+2];

    scanf("%d%*c", &K);
    fgets(S, sizeof(S), stdin);
    S[strlen(S)-1] = '\0';

    if(K >= strlen(S)){
        printf("%s\n", S);
    }else{
        for(int i = 0; i < K; i++){
            printf("%c", S[i]);
        }
        printf("...\n");
    }

    return 0;
}


Measured memory_bytes: 1648
# include <bits/stdc++.h>
using namespace std;
const int maxn=100+50;
int main ()
{
	int a,b;
	cin>>a>>b;
	char s[maxn][maxn];
	int m[maxn]={0},x[maxn]={0};
	for (int i=1;i<=a;++i)
	   	 for (int j=1;j<=b;++j)
	   	     cin>>s[i][j];
	for (int i=1;i<=a;++i)
	    {
	    	int sum=0,j;
	    	for ( j=1;j<=b;++j)
	    	   	if (s[i][j]=='#')
	    	   	     break;
	            if (j==b+1)
                   m[i]=1;
		}
		for (int j=1;j<=b;++j)
	    {
	    	int sum=0,i;
	    	for (i=1;i<=a;++i)
	    	   	if (s[i][j]=='#')
	    	   	     break;
	        if (i==a+1)
	             x[j]=1; 
		}
		for (int i=1;i<=a;++i)
		    {
		    	if (m[i]==1) continue;
		      for (int j=1;j<=b;++j)
		           if (!x[j])
		   	       printf ("%c",s[i][j]);
			  printf ("\n");	
			}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int x,y,xx,yy;cin>>x>>y>>xx>>yy;
    int a = x-xx;
    int b = y-yy;
    cout<<xx+b<<" "<<yy-a<<" "<<x+b<<" "<<y-a;
    return 0;
}

Measured memory_bytes: 3560
#include <stdio.h>

#define MAX 100
#define INF 1000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAX][MAX];

void dijkstra();



int main(){
  int i, j, k, c, u, v;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j] = INF;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      M[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}


void dijkstra() {
  int i, u, v, minv, d[MAX], color[MAX];

  for(i=0;i<n;i++){
    d[i] = INF;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INF;
    u = -1;
    for(i=0;i<n;i++) {
      if(minv>d[i] && color[i]!=BLACK) {
        u = i;
        minv = d[i];
      }
    }
    if(u==-1) break;
    color[u] = BLACK;
    for(v=0;v<n;v++) {
      if(color[v]!=BLACK && M[u][v]!=INF){
        if(d[v]>d[u]+M[u][v]){
          d[v] = d[u] + M[u][v];
          color[v] = GRAY;
        }
      }
    }
  }

  for(i=0;i<n;i++) printf("%d %d\n",i,(d[i] == INF? -1 : d[i]));


  }



Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  int n,x;
  int d=-1;
  cin >> n >>x;
  int m[n];
  for(int i=0;i<n;i++){
    cin >> m[i];
    x-=m[i];
    d++;
  }
sort(m,m+n);
while(x>=0){
   x-=m[0];
   d++;
}
cout << d << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#define ll long long int

int main(void){
		int n;
		scanf("%d", &n);
		int max = -1000001;
		int min = 1000001;
		ll sum = 0;
		for(int i = 0; i < n; i++){
				int a;
				scanf("%d", &a);
				if(max < a)max = a;
				if(min > a)min = a;
				sum += a;
		}
		printf("%d %d %lld\n", min, max, sum);
		return 0;
}



Measured memory_bytes: 2740
import sys 
input = sys.stdin.readline
from heapq import heappop,heappush

class BIT:
    def __init__(self, n):
        self.tree = [1]*(n+1)
        self.size = len(self.tree)
        self.tree[0] = 0
 
    def build(self):
        for i in range(self.size):
            j = i + (i & (-i))
            if j < self.size:
                self.tree[j] += self.tree[i]
    def sum(self, i):
        # [0, i) の要素の総和を返す
        s = 0
        while i:
            s += self.tree[i]
            i -= i & -i
        return s
    # 0 index を 1 index に変更  転倒数を求めるなら1を足していく
    def add(self, i, x):
        while i < self.size:
            self.tree[i] += x
            i += i & -i

    # 総和がx以上になる位置のindex をbinary search
    def bsearch(self,x):
        le = 0
        ri = 1<<(self.size.bit_length()-1)
        while ri > 0:
            if le+ri < self.size and self.tree[le+ri]<x:
                x -= self.tree[le+ri]
                le += ri
            ri >>= 1
        return le+1

h,w = map(int,input().split())
bit = BIT(w+3)
bit.build()

q = [0]*(w)
dp = [0]*(w+3)
dp[0] = -1
rm_q = []

for i in range(h):
    a,b = map(int,input().split())
    for x in [a-1,b+1]:
        if x == 0 or x == w+1:
            continue
        if dp[x] != -1:
            continue
        k = bit.sum(x)
        if k >= 1:
            xl = bit.bsearch(k)
            dp[x] = dp[xl]+(x-xl)
            bit.add(x,1)
            heappush(q,dp[x])
    k = bit.sum(a-1)+1
    while True:
        x = bit.bsearch(k)
        if x > b:
            break
        bit.add(x,-1)
        heappush(rm_q, dp[x])
        dp[x] = -1
    while rm_q and rm_q[0] == q[0]:
        heappop(rm_q)
        heappop(q)
    if q == []:
        print(-1)
    else:
        print(q[0]+i+1)
    

Measured memory_bytes: 125572
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    int a[2][100];

    int aij;

    REP(i, 2) REP(j, n) {
        cin >> aij;
        a[i][j] = aij;
    }

    int maxScore = 0;
    
    REP(k, n) {
        int score = 0;

        for (int j = 0; j <= k; j++)
            score += a[0][j];
        for (int j = k; j < n; j++)
            score += a[1][j];

        maxScore = max(maxScore, score);
    }

    cout << maxScore << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	int a[100000];
	int cnt[100000] = {};
	rep(i, n) {
		cin >> a[i]; cnt[a[i]]++;
	}
	bool f = true;
	if (n % 2) {
		for (int i = n - 1; i >= 1; i--) {
			if (i % 2) {
				if (cnt[i] > 0)f = false;
			}
			else {
				if (cnt[i] != 2)f = false;
			}
		}
		if (cnt[0] != 1)f = false;
	}
	else {
		for (int i = n - 1; i >= 0; i--) {
			if (i % 2) {
				if (cnt[i] != 2)f = false;
			}
			else {
				if (cnt[i] > 0)f = false;
			}
		}
	}
	if (f) {
		int d = n / 2;
		ll out = 1;
		rep(i, d) {
			out = out * 2 % MOD;
		}
		cout << out << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<queue>
using namespace std;
const int INF=1e9;
const int drx[4]={0,-1,1,0};
const int dry[4]={1,0,0,-1};
char str[1010];
bool a[1010][1010];
int dis[1010][1010];
struct node{
	int x,y;
};
queue<node> q;
int n,m,k;
bool out(int x,int y){
	if(x<1||x>n) return 1;
	if(y<1||y>m) return 1;
	return 0;
}
int Min(int x,int y){
	return x<y?x:y;
}
int Abs(int x){
	return x>0?x:-x;
}
int xsqz(int x){
	if(x==0) return 0;
	return (x-1)/k+1;
}
int getdis(int x,int y){
	if(x==1||x==n||y==1||y==m)
		return xsqz(dis[x][y]);
	int d=Min(Min(Abs(x-1),Abs(x-n)),Min(Abs(y-1),Abs(y-m)));
	if(dis[x][y]<k)
		return xsqz(d)+1;
	else
		return xsqz(d+dis[x][y]);
}
int main(){
//	freopen("C.in","r",stdin);
	scanf("%d%d%d",&n,&m,&k);
	node st;
	for(int i=1;i<=n;i++){
		scanf("%s",str+1);
		for(int j=1;j<=m;j++){
			if(str[j]=='#') a[i][j]=1;
			else a[i][j]=0;
			if(str[j]=='S')
				st=(node){i,j};
			dis[i][j]=-1;
		}
	}
	if(st.x==1||st.x==n||st.y==1||st.y==m){
		printf("0\n");
		return 0;
	}
	int x,y,xx,yy;
	q.push(st);
	dis[st.x][st.y]=0;
	int ans=INF;
	while(!q.empty()){
		st=q.front();
		q.pop();
		ans=Min(getdis(st.x,st.y),ans);
		x=st.x,y=st.y;
		for(int i=0;i<4;i++){
			xx=x+drx[i],yy=y+dry[i];
			if(out(xx,yy)) continue;
			if(a[xx][yy]) continue;
			if(dis[xx][yy]==-1){
				dis[xx][yy]=dis[x][y]+1;
				q.push((node){xx,yy});
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

int main(void) {
  int N, X, b=0, cnt=1;
  cin >> N >> X;
  int L[N];
  
  for(int i=0; i<N; i++) cin >> L[i];
  
  for(int i=0; i<N; i++){
    b += L[i];
    if(b <= X){
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
  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 gcd(int p, int q) {
	if (p % q == 0) return q;
	return gcd(q, p % q);
}

int main() {

	int k;
	cin >> k;

	long long ans = 0;
	for (int i = 1;i <= k;i++) {
		for (int j = 1;j <= k;j++) {
			for (int l = 1;l <= k;l++) {
				ans += gcd(gcd(i, j), gcd(l,j));
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define all(x) x.begin() , x.end()
#define ll long long 
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s ; cin>>s;
    for(int i = 1 ; i < s.size(); ++i){
        if(s[i] == s[i - 1]){
            return cout<<"Bad\n" , 0;
        }
    }
    cout<<"Good\n";

}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int h, w;
  cin >> h >> w;
  vs a(h);
  re(i, h) cin >> a[i];

  re(i, w+2) cout << '#';
  cout << endl;
  re(i, h) cout << '#' << a[i] << '#' << endl;
  re(i, w+2) cout << '#';
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, l;
  cin >> n >> l;
  for (int i = 0; i < n; i++) cin >> as[i];

  int k = 0;
  for (; k < n - 1; k++)
    if (as[k] + as[k + 1] >= l) break;

  if (k >= n - 1) puts("Impossible");
  else {
    puts("Possible");
    for (int i = 0; i < k; i++) printf("%d\n", i + 1);
    for (int i = n - 2; i >= k; i--) printf("%d\n", i + 1);
  }
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define Yes(n) cout<<((n)?"Yes\n":"No\n")
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {}
template<class T> bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll N, vector<ll> v){
    sort(all(v));
    double sum = v.at(0) * pow(0.5, (int(v.size()) - 1));
    rep2(i, 1, (int(v.size()) - 1)) sum += v.at(i) * pow(0.5, int(v.size()) - i);
    cout << sum << "\n";
}

int main() {
    ll N;
    ignore_ret(scanf("%lld",&N));
    vector<ll> v(N);
    for(int i = 0 ; i < N ; i++){
        ignore_ret(scanf("%lld",&v[i]));
    }
    solve(N, move(v));
    return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = 0
for i in range(1, N + 1, 2):
    cnt = 0
    for j in range(1, int(i**0.5) + 1):
        if i % j == 0:
            if i // j != j: cnt += 1
            cnt += 1
    if cnt == 8: ans += 1
print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader	br    = null;
	private	static	int[]			month = { 4, 0, 1, 4, 6, 2, 4, 0, 3, 5, 1, 3 };
	private	static	String[]		youbi = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };

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

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[]	aDate = null;

		while((aDate = parseDate()) != null) {
			if (aDate[0] == 0 && aDate[1] == 0) {
				break;
			}

			System.out.println(youbi[(month[aDate[0]-1] + aDate[1] - 1) % 7]);
		}
	}

	private static int[] parseDate() {
		int[]	aDate = null;
		String	strIn = null;

		if ((strIn = parseStdin()) != null) {
			String[]	aN = strIn.split(" ");
			aDate    = new int[2];
			aDate[0] = Integer.parseInt(aN[0]);
			aDate[1] = Integer.parseInt(aN[1]);
		}
		
		return aDate;
	}

	private static String parseStdin() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}
}

Measured memory_bytes: 16928
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

#define loop(i, a, b) for(long long int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define MAX (1000000)

int main()
{
  bool prime[MAX];
  rep(i, MAX) prime[i] = true;
  prime[0] = prime[1] = false;
  loop(i, 2, 10001){
    //	cout << i << endl;
    for(long long int j = i * 2; j < MAX; j += i)
      prime[j] = false;
  }

  int n;
  while(cin >>  n, n != 0){
    long long int ans = 0, cnt = n;
    rep(i, MAX)
      if(prime[i] == true) {
	//cout << i << endl;
	ans += i; cnt--;
	if(!cnt) break;
      }
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 2132
from collections import Counter
s = input()
a = [0]
mod = 2019
for i,j in enumerate(s[::-1]):
    a.append(a[-1]+int(j)*pow(10,i,mod))
    a[-1] %= mod
b = Counter(a)
ans = 0
for i in b.values():
    ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 16732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100;
const ll mod = 1000000007;
int main(){
int n;
cin>>n;
vector<int>a(n);
for(int i=0;i<n;i++)cin>>a.at(i);
  bool check=true;
  int cnt=0;
for(int i=0;i<n-1;i++){
    if((cnt==1&&a[i]>a[i+1])||a.at(i)-a.at(i+1)>1)check=false;
    else if(a[i]>a[i+1])cnt++;
    else if(a[i]<a[i+1])cnt=0;
  
}
if(check)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}





Measured memory_bytes: 640
#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using vi = vector<int>;
const int maxn = 303;
char get(int a, int b, int s, int l, int i) {
	if(i < l + (l/s)) return i%(s+1) == s ? 'B' : 'A';
	if(i >= a + b - (a-l-1)*(s+1)) {
		i -= a + b - (a-l-1)*(s+1);
		return i%(s+1) == 0 ? 'A' : 'B';
	}
	i -= l + (l/s);
	return i == 0 ? 'A' : 'B';
}
void solve() {
	int A, B, C, D, rev = 0;
	cin >> A >> B >> C >> D;
	if(A < B) swap(A, B), rev = 1;
	int S = (A+B)/(B+1);
	int l = 0;
	for(int i = 1<<29; i>>=1;) {
		l += i;
		if(l > A || ((l/S) + (A-l-1)*1ll*S < B+(l==A))) l-= i;
	}
	int cnt = 0;
	while(((l/S) + (A-l-1)*1ll*S >= B+(l==A))) ++l <= A, assert(++cnt < 2);
	//cout << l << '\n';
	C--, D--;
	while(C <= D) {
		if(!rev) cout << get(A, B, S, l, C);
		else cout << char(get(A, B, S, l, A+B-C-1)^'A'^'B');
		C++;
	}
	cout << '\n';
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	int t;
	cin >> t;
	while(t--) solve();
}
//0 1 0 1 0 1 0 1 2 2


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
int n;
struct edge {
	int to, nxt;
}eg[maxn * 2 + 10];
int h[maxn + 10], egcnt;

inline void addeg(int &h, int to) {
	eg[++egcnt] = (edge){to, h};
	h = egcnt;
}

int dfs(int p, int fa) {
	int ans = 0;
	for (int i = h[p]; i; i = eg[i].nxt)
		if (eg[i].to != fa) ans ^= dfs(eg[i].to, p) + 1;
	return ans;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int l, r; scanf("%d%d", &l, &r);
		addeg(h[l], r); addeg(h[r], l);
	}
	printf("%s", dfs(1, 0) ? "Alice" : "Bob");
}


Measured memory_bytes: 6912
#include <stdio.h>

int main(void)
{
	int i,v,j,k,N;
	scanf("%d", &N);
	int a[N];
	
	for(i=0; i<N; i++){
		scanf("%d", &a[i]);
	}
	
	for(i=0; i<N; i++){
		if (i < N-1){
			printf("%d ", a[i]);
		}
		else{
			printf("%d", a[i]);
		}
	}
	printf("\n");
	
	for(i=1; i<N; i++){
		v=a[i];
		j=i-1;
		while(j>=0 && a[j]>v){
			a[j+1] = a[j];
			j--;
			a[j+1] = v;
		}
		for(k=0; k<N; k++){
			if (k < N-1){
				printf("%d ", a[k]);
			}
			else{
				printf("%d", a[k]);
			}
		}
		printf("\n");	
	}
	return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int n,a,b,c,d;
string s;

bool step(int &p){
  bool ok=1;
  if(s[p+1]=='.'&&p+1!=b)p++;
  else{
   if(s[p+2]=='.'&&p+2!=b)p+=2;
   else ok=0;
  }
  return ok;
}

int main(){cout<<fixed<<setprecision(10);
          
           cin>>n>>a>>b>>c>>d>>s;
           a--;b--;c--;d--;
           bool ans=true;
           rep(i,0,n){
            while(a!=c&&step(a));
            if(b!=d)step(b);
             if(a==c&&b==d)break;
             //cout<<a<<b<<endl;
           }
              ans=(a==c&&b==d);
              Yes(ans);
          }

Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {
	/**
	 * Low Elements
	 * @param 1 ≤ N ≤ 2 × 10^5
	 */
	public static void main(String... args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] p = new int[n];
			int tmp = Integer.MAX_VALUE;
			int count = 0;
			for (int i = 0; i < n; i++) {
				p[i] = sc.nextInt();
				if (tmp > p[i]) {
					tmp = p[i];
					count ++;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 85720
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


//const int mod=1000000007;
const int mod=998244353;



int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r;
    cin >> n;
    int v[n][3],dp[n][3];
    memset(dp,0,sizeof(dp));
    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++){
            cin >> v[i][j];
        }
    }
    dp[0][0]=v[0][0];
    dp[0][1]=v[0][1];
    dp[0][2]=v[0][2];
    for(int i=1; i<n; i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+v[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+v[i][1];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+v[i][2];
    }
    cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << el;
    
    
    return 0;
}


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

const int N = 1e5+5;

int a[N];
int h[2][N];
pair<int, int> h2[2][N];

int main() {
    int n; scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", a+i);
        ++h2[i%2][a[i]].first;
        h2[i%2][a[i]].second = a[i];
    }
    sort(h2[0], h2[0]+N, greater<pair<int, int>>());
    sort(h2[1], h2[1]+N, greater<pair<int, int>>());
    int x, y;
    x = h2[0][0].second;
    y = h2[1][0].second;
    if (h2[0][0].second == h2[1][0].second) {
        if (h2[0][0].first + h2[1][1].first > h2[0][1].first + h2[1][0].first) {
            x = h2[0][0].second;
            y = h2[1][1].second;
        } else {
            x = h2[0][1].second;
            y = h2[1][0].second;
        }
    }
    //cout << x << ' ' << y << endl;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (i%2 == 0 && a[i] != x) ++ans;
        if (i%2 == 1 && a[i] != y) ++ans;
    }
    printf("%d", ans);
    
    return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>

int main(void){
	int N,x,y,Tile;
	int i;
	scanf("%d",&N);
	scanf("%d",&Tile);

	for(i=0;i<Tile;i++){
		scanf("%d %d",&x,&y);

		if(x*2>N) x=N-x+1;//入力されたｘ座標から見て端から短い方の距離をｘとする
		if(y*2>N) y=N-y+1;

		if(x<y) printf("%d\n",(x-1)%3+1);//短い方の距離を3で割った余りが答えになる。
		else printf("%d\n",(y-1)%3+1);
	}
	return 0;
}

Measured memory_bytes: 1024
import Data.Ratio ((%),numerator,denominator)
import Data.Char (intToDigit)

type N = Integer
type K = Integer
type M = Int
type R = Int

main = do
    [n,k,m,r] <- getLine >>= return . map read . words :: IO [Int]

    if all (==0) [n,k,m,r] then return () else do
        let
            n' = fromIntegral n
            k' = fromIntegral k
        putStrLn $ solve ((fromIntegral n),(fromIntegral k),m,r)
        main    

solve :: (N,K,M,R) -> String
solve (n,k,m,r) = toString r $ p m n

p :: M -> N -> Rational
p 0 n = 1 % n
p 1 n = p 0 n + (harmonicTo (n-1)) / (fromIntegral n)

harmonicTo :: Integer -> Rational
harmonicTo n = harmonicTo' 0 1 1
    where
    harmonicTo' a b n'
        | n' > n = a % b
        | otherwise = g `seq` harmonicTo' ((a*n'+b)`div`g) ((b*n')`div`g) (n'+1)
        where
        g = gcd b n'
{--
harmonicTo n = sum $ map (1 %) [1..n]
--}

toString :: R -> Rational -> String
toString r p = insertDot $ toString' (numerator p) (denominator p) 0
    where
    insertDot (c:cs) = c:'.':cs
    toString' a b r'
        | r' <= r   = d : toString' a' b (r'+1)
        | otherwise = []
        where
        d = intToDigit $ fromIntegral (a `div` b)
        a' = 10 * (a `mod` b)

Measured memory_bytes: 44312
#include<bits/stdc++.h>
#include <sstream>
#define pi 3.1416
using namespace std;
/*double Convert(double radian)
{
    return(radian*(180/pi));
}*/
int main()
{
    int m,count=0;
    double b,sum=0,p=0;
    cin>>m>>b;
    int arr[m];
    for(int i=0;i<m;i++)
    {
        cin>>arr[i];
        sum=sum+arr[i];
    }
    p=(1/(4*b))*sum;
    sort(arr,arr+m,greater<int>());
    for(int i=0;i<b;i++)
    {
        if(arr[i]>=p)
        {
            count++;
        }
    }
    if(count==b)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }

}






Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	char str[9];
	while(cin >> str)
	{
		if(str[0] == str[1] && str[0] == str[2] && str[0] != 's')
		{
			cout << str[0] << endl;
		}
		else if(str[3] == str[4] && str[3] == str[5] && str[3] != 's')
		{
			cout << str[3] << endl;
		}
		else if(str[6] == str[7] && str[6] == str[8] && str[6] != 's')
		{
			cout << str[6] << endl;
		}
		else if(str[0] == str[3] && str[0] == str[6] && str[0] != 's')
		{
			cout << str[0] << endl;
		}
		else if(str[1] == str[4] && str[1] == str[7] && str[1] != 's')
		{
			cout << str[1] << endl;
		}
		else if(str[2] == str[5] && str[2] == str[8] && str[2] != 's')
		{
			cout << str[2] << endl;
		}
		else if(str[0] == str[4] && str[0] == str[8] && str[0] != 's')
		{
			cout << str[0] << endl;
		}
		else if(str[2] == str[4] && str[2] == str[6] && str[2] != 's')
		{
			cout << str[2] << endl;
		}
		else
		{
			cout << "d" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<string>
using namespace std;
typedef long long ll;

int main(void) {
	string s;
	cin >> s;
	map<char, int>alpha;
	for (ll i = 0;i < s.length();i++) {
		alpha[s[i]]++;
	}
	for (char a = 'a';a <= 'z';a++) {
		if (alpha[a] == 0) {
			cout << a << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 512
import sys
import math
from math import sqrt
from collections import deque
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)

h,w=map(int,input().split())
miti=[]
for i in range(h):
    miti.append(input())
    

def bfs(x,y):
    for i,j in [[x+1,y],[x,y+1],[x-1,y],[x,y-1]]:
        if i<0 or h<=i or j<0 or w<=j :continue
        if dist[i][j] != -1:continue
        if miti[i][j]=="#":continue
        dist[i][j]=dist[x][y]+1
        queue.append([i,j])
    while queue:
        t,r=queue.popleft()
        bfs(t,r)
ans=0
for i in range(h):
    for j in range(w):
        if miti[i][j]=="#":continue
        dist=[[-1 for i in range(w)] for j in range(h)]
        dist[i][j]=0
        queue=deque([])
        bfs(i,j)
        
        
        for s in range(h):
            for t in range(w):
                ans=max(ans,dist[s][t])
print(ans)


Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
int main() {
  long long X;
  cin >> X;
  long long a = 100;
  int i = 0;
  while(a < X){
    a = a + (a/100);
    i ++;
  }
  cout << i << endl;
}

Measured memory_bytes: 3616