akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);
	
	LL n, k, ans = 0;
	string s;
	cin >> s >> k;
	n = SZ(s);
	
	bool vsi = 1;
	FOR(i, 1, n)
		vsi &= s[i] == s[0];
	
	if (vsi)
	{
		ans = (k * n) / 2;
		cout << ans << endl;
		return 0;
	}
	
	VI tut;
	int cnt = 1;
	FOR(i, 1, n)
		if (s[i] == s[i - 1])
			cnt++;
		else
		{
			tut.PB(cnt);
			cnt = 1;
		}
	
	tut.PB(cnt);
	int styk = 0;
	if (s[0] == s[n - 1])
		styk = tut[0] + tut.back();
	
	FOR(i, 1, SZ(tut) - 1)
		ans += k * (tut[i] / 2);
	
	if (styk)
	{
		ans += (k - 1) * (styk / 2);
		ans += (tut[0] / 2);
		ans += (tut.back() / 2);
	}
	else
	{
		ans += k * (tut[0] / 2);
		ans += k * (tut.back() / 2);
	}
	
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int k,a,b;
	cin>>k;
	cin>>a>>b;
	int lol = a/k;
	lol*=k;
	if(lol==a) {
		cout<<"OK";
	}	
	else if(lol+k<=b) {
		cout<<"OK";
	}
	else {
		cout<<"NG";
	}

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

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

    int r = 0;
    for (int i = 1; i <= n; i += 2) {
    	int c = 0;
        for (int j = 1; j <= n; j++) {
            if (i % j == 0) {
                c++;
            }
        }
        if (c == 8) {
            r++;
        }
    }

    cout << r << endl;

    return 0;
}

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

int main(){
	string n;
	cin >> n;
	bool ans=false;
	for(int i=0;i<3;i++){
		if(n[i]=='7')ans=true;
	}
	if(ans){
		cout << "Yes";	
	}else{
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 3624
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

	ll n, a[6];
int main() {
	ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

    forn(i, 1, 4) cin >> a[i];
    cin >> n;
    a[2] = min(a[2], a[1] * 2);
    a[3] = min(a[3], a[2] + a[2]);
    a[4] = min(a[4], a[3] + a[3]);

    cout << a[4] * (n / 2) + a[3] * (n & 1) << "\n";

	return 0;
}


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

int main(){
  int h,w;
  char m[52][52];
  char a;
  cin>>h>>w;
  rep(i,52) rep(j,52) m[i][j]='0';
  repi(i,1,h+1){
    repi(j,1,w+1){
      cin>>a;
      if(a=='#'){
        m[i][j]='#';
	if(m[i-1][j-1]!=35) m[i-1][j-1]+=1;
	else m[i-1][j-1]='#';
	if(m[i-1][j]!=35)	m[i-1][j]+=1;
	else m[i-1][j]='#';
	if(m[i-1][j+1]!=35)	m[i-1][j+1]+=1;
	else m[i-1][j+1]='#';
	if(m[i][j+1]!=35)	m[i][j+1]+=1;
	else m[i][j+1]='#';
	if(m[i+1][j+1]!=35)	m[i+1][j+1]+=1;
	else m[i+1][j+1]='#';
	if(m[i+1][j]!=35)	m[i+1][j]+=1;
	else m[i+1][j]='#';
	if(m[i+1][j-1]!=35)	m[i+1][j-1]+=1;
	else m[i+1][j-1]='#';
	if(m[i][j-1]!=35)   m[i][j-1]+=1;
	else m[i][j-1]='#';
      }
    }
  }
  repi(i,1,h+1){
    repi(j,1,w+1){
      cout<<m[i][j];}
    cout<<endl;
  }
  
  

  return 0;
}







Measured memory_bytes: 256
/* -> Written by <-
   -----------
  |K_A_Z_A_M_A|
  |___________|
  |    _    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/

#define Task ""
#define F first
#define S second
#define push_back pb
#define bit(x, i) (x >> i) & 1
#define inf 1e9 + 7
#define INF 1e18 + 7

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;
const int maxn = 2e5 + 5;

int a;

void Solve()
{
    cin >> a;
    int res = 0;
    int b = a;
    for (int i = 1; i <= 3; i ++)
    {
        res += b;
        b = b * a;
    }
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    if(fopen(Task".inp", "r"))
    {
        freopen(Task".inp","r",stdin);
        freopen(Task".out","w",stdout);
    }
    int test_case = 1;
//    cin >> test_case;
    while (test_case --)
        Solve();
    return 0;
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    for (int i = 0; i < N; i++)
    {
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    int sum = 0;
    for (int i = 0; i < K; i++)
    {
        sum += l[N - i - 1];
        //        cout << sum << endl;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(){
	string s;
	long n=0,m;
	cin>>s;
	//cin>>n;
	/*n=(n-1)%s.length()+1;
	cout<<s[n-1]<<endl;*/
	for(int i=1;i<s.length();i++){
		if(s[i-1]!=s[i]){
			n++;
		}
	}
	cout<<n<<endl;
	return 0;
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    /* ll t;
    cin>>t;
    while(t--) */
    {
        ll i,j,k,l,m,n,a,b,c,d,cnt=0,p,q;
        string s,str="ARC",str1="ABC";
        cin>>s;
        if(s==str)
            cout<<str1<<endl;
        else
            cout<<str<<endl;




    }
}


Measured memory_bytes: 3628
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{it.toDouble()}
    val b = a.sorted()
    var ans : Double = b[0]
    for(i in 1 until n) ans = (ans + b[i]) / 2
    println("%.10f".format(ans))
}

Measured memory_bytes: 38000
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() -> () {
    input!{
        n: [u8; 3],
    }
    let mut n = n;
    n.sort();
    println!("{}", n[2] * 10 + n[1] + n[0]);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include <functional>
using namespace std;
long long ans=1,cnt;
int n,a[100005],j;
main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n,greater<int>());
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            j++;
          	i++;
            ans*=a[i];
        }
        if(j==2)break;
    }
    cout<<(j==2?ans:0)<<endl;
}

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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   ll A, B, maxAB, minAB;
   cin >> A >> B;
   maxAB = max(A, B);
   minAB = min(A, B);
   for (int i = 1; i <= minAB; i++) {
     if (maxAB * i % minAB == 0) {
       cout << maxAB * i << endl;
       break;
     }
   }
 }


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

/*小数点以下の長さを指定
cout << fixed << setprecision(15) << y << endl;
*/

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}


int main() {
	string s, t;
	cin >> s >> t;
	
	int MAX = 10000000;
	rep(i, s.size() - t.size() + 1) {
		int temp = 0;
		rep(j, t.size()) {
			if (s[i+j] != t[j]) {
				temp++;
			}
		}
		MAX = min(MAX, temp);
	}

	cout << MAX << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
int main()
{
    int i;
    char a[12];
    for(i=0;i<12;i++) scanf("%c",&a[i]);
    for(i=0;i<4;i++) printf("%c",a[i]);
    printf(" ");
    for(int i=4;i<12;i++) printf("%c",a[i]);
    printf("\n");
return 0;
}

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

int main(void)
{
	long long X, Y;
	cin >> X >> Y;

	string ret;
	if(abs(X-Y) <= 1)
		ret = "Brown";
	else
		ret = "Alice";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    A = LI()
    from collections import Counter
    cnt = Counter(A)
    if N % 2 and cnt[0] < 0:
        return 0
    for i in range(N % 2 + 1, N, 2):
        if cnt[i] != 2:
            return 0
    ans = (2 ** (N // 2)) % MOD

    return ans

print(main())

Measured memory_bytes: 14884
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = Integer.parseInt(in.nextLine());
        final int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
            arr[i] -= i + 1;
        }
        in.nextLine();
        Arrays.sort(arr);
        System.out.println(f(arr, arr[n / 2]));
    }

    private static long f(int[] arr, int median) {
        long res = 0;
        for (int value : arr) {
            res += Math.abs(value - median);
        }
        return res;
    }
}


Measured memory_bytes: 60484
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

// a[i] == b[i]なら意味がないので無視
int siz = 3000000;

int main(){
    ll n;
    cin >> n;
    vector<int> a(3), b(3);
    for(int i = 0; i < 3; i++)  cin >> a[i];
    for(int i = 0; i < 3; i++)  cin >> b[i];
    if(a[0]>=b[0]&&a[1]>=b[1]&&a[2]>=b[2]){
        // btoa
        vector<ll> dp(n+1, 0);
        for(int i = 0; i < 3; i++){
            if(a[i] == b[i])    continue;
            for(int j = b[i]; j <= n; j++){
                dp[j] = max(dp[j], dp[j-b[i]] + (a[i]-b[i]));
            }
        }
        ll ans = 0;
        for(int i = 0; i <= n; i++){
            ans = max(ans, dp[i]);
        }
        cout << n+ans << endl;
    }else if(a[0]<=b[0]&&a[1]<=b[1]&&a[2]<=b[2]){
        // atob      
        vector<ll> dp(n+1, 0);
        for(int i = 0; i < 3; i++){
            if(a[i] == b[i])    continue;
            for(int j = a[i]; j <= n; j++){
                dp[j] = max(dp[j], dp[j-a[i]] + (b[i]-a[i]));
            }
        }
        ll ans = 0;
        for(int i = 0; i <= n; i++){
            ans = max(ans, dp[i]);
        }
        cout << n+ans << endl;
    }else{
        vector<int> atob, btoa;
        for(int i = 0; i < 3; i++){
            if(a[i] > b[i])         btoa.push_back(i);
            else if(a[i] < b[i])    atob.push_back(i);
        }
        if(atob.size() == 1){
            int k = atob[0];
            n = n/a[k]*b[k] + n%a[k];
            // dp
            vector<ll> dp(n+1, 0);
            for(int k = 0; k < btoa.size(); k++){
                int i = btoa[k];
                for(int j = b[i]; j <= n; j++){
                    dp[j] = max(dp[j], dp[j-b[i]] + (a[i]-b[i]));
                }
            }
            ll ans = 0;
            for(int i = 0; i <= n; i++) ans = max(ans, dp[i]);
            cout << n+ans << endl;
        }else if(atob.size() == 2){
            vector<ll> dp(n+1, 0);
            for(int k = 0; k < atob.size(); k++){
                int i = atob[k];
                for(int j = a[i]; j <= n; j++){
                    dp[j] = max(dp[j], dp[j-a[i]] + (b[i]-a[i]));
                }
            }
            ll ans = 0;
            for(int i = 0; i <= n; i++) ans = max(ans, dp[i]);
            ans += n;
            if(btoa.size() == 1){
                int k = btoa[0];
                ans = ans%b[k] + ans/b[k]*a[k];
            }
            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 193536
#include <iostream>
#include <algorithm>
#include<functional>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main() {
	int N;
	int n[100040];
	int time = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> n[i];
	}
	if (N == 1) {
		cout << "Yes";
	}
	else {
		for (int i = 0; i < N - 1; i++) {
			if (i == 0) {
				if (n[0] - 1 > n[1]) {
					time = 1;
					break;
				}
				n[0] = n[0] - 1;
			}
			else {
				if ((n[i + 1] >= n[i]) && (n[i] > n[i - 1])) {
					n[i] = n[i] - 1;				
				}
				else if (n[i + 1]< n[i] - 1) {
					time = 1;
					break;
				}
				else if (n[i + 1] == n[i] - 1) {
					if (n[i] - 1 < n[i - 1]) {
						time = 1;
						break;
					}
					n[i] = n[i] - 1;
				}

			}
		
		}
		if (time == 1) {
			cout << "No";
		}
		else {
			cout << "Yes";
		}
	
	
	}
}

Measured memory_bytes: 640
import std.array, std.stdio, std.conv, std.string, std.math, std.random, std.range,std.functional;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.comparison;


struct Point
{
    double x, y;

    Point opBinary(string op)(Point rhs)
    {
        return mixin("Point(x "~op~" rhs.x, y "~op~" rhs.y)");
    }
    Point opBinary(string op)(double rhs)
    {
        return mixin("Point(x "~op~" rhs, y "~op~" rhs)");
    }
    string toString()
    {
        return format("%f %f", x, y);
    }

}

void main()
{
    int N = readln().strip.to!int;

    void func(int n, Point start, Point goal)
    {
        if(n==0)
        {
            return;
        }
        Point s = start+((goal-start)/3);
        Point t = goal-(goal-start)/3;
        Point u = Point(
            (t.x-s.x)*cos(PI*2/6) - (t.y-s.y)*sin(PI*2/6)+s.x,
            (t.x-s.x)*sin(PI*2/6) + (t.y-s.y)*cos(PI*2/6)+s.y 
        );
        func(n-1, start, s);
        writeln(s);
        func(n-1, s, u);
        writeln(u);
        func(n-1, u, t);
        writeln(t);
        func(n-1, t, goal);
    }
    writeln(Point(0, 0));
    func(N, Point(0, 0), Point(100, 0));
    writeln(Point(100, 0));
}


sizediff_t minIndex(alias pred="a<b", R) (R list)
    if(isForwardRange!R && !isInfinite!R && is(typeof(binaryFun!pred(list.front, list.front))))
{
    assert(!list.empty);
    typeof(list.front) min = list.front;
    sizediff_t minPos;
    sizediff_t curPos;
    for(list.popFront(); !list.empty; list.popFront())
    {
        curPos++;

        if(binaryFun!pred(list.front, min))
        {
            min = list.front;
            minPos = curPos;
        }
    }
    return minPos;
}



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

signed main()
{
  int n;
  cin>>n;
  string s;

  map<string,int> mp;

    mp["AC"] = 0;
    mp["WA"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;
    for(int i = 0;i < n;i++)
    {
      cin>>s;
      mp[s]++;
    }
    int i = 0;
    for(auto& it :mp)
    {
      if(it.first == "AC")
      {
      cout<<it.first<<" "<<"x"<<" "<<it.second<<"\n";
     }
   }
   for(auto& it :mp)
   {
     if(it.first == "WA")
     {
     cout<<it.first<<" "<<"x"<<" "<<it.second<<"\n";
    }
  }
  for(auto& it :mp)
  {
    if(it.first == "TLE")
    {
    cout<<it.first<<" "<<"x"<<" "<<it.second<<"\n";
   }
 }
 for(auto& it :mp)
 {
   if(it.first == "RE")
   {
   cout<<it.first<<" "<<"x"<<" "<<it.second<<"\n";
  }
}

  return 0;
}


Measured memory_bytes: 3656
# dp[w] i番目までの品物で、重さがw以下になるよう選んだときの価値の最大値。
# 参考 https://qiita.com/drken/items/68b8503ad4ffb469624c

import numpy as np

# 入力
# 重さと価値はループのなかで都度取得する
N, W = map(int, input().strip().split())

# 初期化
dp = np.zeros(W + 1, dtype='int64')

# dpテーブル
for i in range(N):
    w, v = map(int, input().strip().split())
    dp[w:] = np.maximum(dp[w:], dp[:-w] + v)

print(dp[-1])

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

int main(){
  string s; cin>>s;
  int f = 101, c=101;
  int count = 0;
  for(char aa:s){
    if(aa=='F') f=count;
    if(aa=='C' && c==101) c=count;
    count ++;
  }
  if(f!=101 && c!=101 && f>c) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include <sstream>
using namespace std;
int main(void){
    int A,B,C;
    cin>>A>>B>>C;
    if(A<B && B<C) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3064
n, k = map(int, input().split())
a = list(map(int, input().split()))

l, r = 0, max(a)

def ok(m):
    cut = 0
    for x in a:
        cut += (x - 1) // m
    return cut <= k

while r - l > 1:
    m = (l + r) // 2
    if ok(m):
        r = m
    else:
        l = m

print(r)

Measured memory_bytes: 30868
package main
 
import "fmt"
 
func main (){
  var a,b int
  s1 := []int{1,2,3}
  fmt.Scan(&a,&b)
  s2 := remove(s1,a)
  s3 := remove(s2,b)
  fmt.Printf("%d",s3[0])
}
 
func remove(ints []int, n int) []int{
  result := []int{}
  for _, v := range ints{
    if v != n{
      result = append(result, v)
    }
  }
  return result
}


Measured memory_bytes: 512
/*
  AOJ 2131
  Title:Pi is Three
  @kankichi573
*/
#include <stdio.h>
#include <math.h>
#include <float.h>

// #define max(x,y) (((x)>(y))?(x):(y))
// #define min(x,y) (((x)<(y))?(x):(y))

main()
{
  double pai=atan(1)*4;
  double x,d1,d2;
  int m,n;

  while(scanf("%lf",&x) && (x != 0.0))
    {
      if(x >= pai-3)
	{
	  printf("3/1\n");
	  continue;
	}
      for(m=2;m<10000000;m++)
	{
	  n = (double)m*pai;
	  d1=pai-(double)n/(double)m;
	  d2=((double)n+1.0)/(double)m-pai;

	  if(fabs(d2)<x)
	    {
	      printf("%d/%d\n",n+1,m);
	      break;
	    }
	  if(fabs(d1)<x)
	    {
	      printf("%d/%d\n",n,m);
	      break;
	    }
	}
    }
  return(0);
}

Measured memory_bytes: 628
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

int main()
{
  int x;
  cin >> x;
  int dan = 8;
  for (int i = 400; i < 2000; i += 200) {
    if (x >= i && x < i + 200) {
      cout << dan << endl;
    }
    dan--;
  }
}


Measured memory_bytes: 3632
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    vector<string> s(n);
    vector<int> c(5);
    rep(i, n){
        cin >> s[i];
        if(s[i][0] == 'M'){
            c[0]++;
        }else if(s[i][0] == 'A'){
            c[1]++;
        }else if(s[i][0] == 'R'){
            c[2]++;
        }else if(s[i][0] == 'C'){
            c[3]++;
        }else if(s[i][0] == 'H'){
            c[4]++;
        }
    }

    int ans = 0;
    for(int i = 0; i < (1 << 5)-1; i++){
        int x = 1;
        int p = 0;
        for(int j = 0; j < 5; j++){
            if((i >> j) & 1 == 1){
                x *= c[j];
                p ++;
            }
        }
        if(p == 3){
            ans += x;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

template< typename T >
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int N){
        par.assign(N,0);
        rank.assign(N,0);
        REP(i,N) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    void unite(int x,int y){
        x=find(x),y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]) swap(x,y);

        //x becomes root
        par[y]=x;
        if(rank[x]==rank[y]) rank[x]++;
    }
};

template< typename T >
T kruskal(Edges< T > &edges, int V) {
  sort(begin(edges), end(edges), [](const edge< T > &a, const edge< T > &b) {
    return (a.cost < b.cost);
  });
  UnionFind tree(V);
  T ret = 0;
  for(auto &e : edges) {
    if(!tree.same(e.src, e.to)) {
        ret += e.cost;
        tree.unite(e.src, e.to);
    }
  }
  return (ret);
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int V,E; cin >> V >> E;
    Edges<int> edges;
    REP(i,E){
        int a,b,c; cin >> a >> b >> c;
        edges.eb(a,b,c);
    }
    cout << kruskal(edges,V) << endl;

}


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

int main(){
    int div = 1;
    for (int i=0;i<9;i++){
        div *= 10;
    }
    div+=7;
    int N;
    cin >> N;
    int t[N];
    int a[N];
    for (int i=0;i<N;i++){
        cin >>t[i];
    }
    for (int i=0;i<N;i++){
        cin >>a[i];
    }
    int m[N]={};
    int themax[N] = {};
    int certain[N] = {};
    int max = 0;
    for (int i=0;i<N;i++){
        if (t[i]>max){
            max = t[i];
            certain[i] = 1;
            m[i]=1;
        }else{
            m[i]=max;
            themax[i] = max;
        }
    }
    max = 0;
    for (int i=N-1;i>=0;i--){
        if (a[i]>max){
            max = a[i];
            m[i]=1;
            if (certain[i]==1){
                if (a[i]!=t[i]){
                    cout << 0 <<endl;
                    return 0;
                }   
            }else if (a[i]>themax[i]){
                cout << 0 <<endl;
                return 0;
            }
        }else{
            if (certain[i]==1){
                if (t[i]>max){
                    cout << 0 <<endl;
                    return 0;
                }
            }
            m[i] = min(m[i],max);
        }
    }

    long int score = 1;
    for (int i=0;i<N;i++){
        score = score * m[i];
        score = score%div;
    }
    cout << score << endl;
}


Measured memory_bytes: 2176
import Data.Ord (compare)
 
readInt :: String -> Integer
readInt = read
 
main = do
  first <- map readInt . words <$> getLine
  second <- map readInt . words <$> getLine
  putStrLn $ case compare first second of
    LT -> "LESS"
    EQ -> "EQUAL"
    GT -> "GREATER"

Measured memory_bytes: 636
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

#define INF 2e9

#define REP(i,n) for(int i = 0; i < n;++i)
#define REPA(i,a,n) for(int i = a; i < n; ++i)
#define ALL(a) a.begin(), a.end()

using namespace std;

int main(void) {

	int A, B;

	cin >> A >> B;

	cout << (A > B * 2 ? A - (B * 2) : 0) << endl;

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<long> a(N);
  for(int i=0; i<N; i++) cin >> a[i];


  // 全て割り切れなくなるまで続けられる
  int res=0;
  for (int i=0; i<N; i++) {
    while(true) {
      if (a[i]%2 == 0) {
        a[i] = a[i]/2;
        res++;
      } else break;
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 384
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}

fn read<T: std::str::FromStr>() -> T where T::Err: std::fmt::Debug {
    read_line().trim().parse().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T>
where T::Err: std::fmt::Debug {
    read_line().split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn read2<T1: std::str::FromStr, T2: std::str::FromStr>() -> (T1, T2)
where T1::Err: std::fmt::Debug, T2::Err: std::fmt::Debug {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut splitted = s.split_whitespace();
    let v1: T1 = splitted.next().unwrap().parse().unwrap();
    let v2: T2 = splitted.next().unwrap().parse().unwrap();
    (v1, v2)
}

fn read3<T1: std::str::FromStr, T2: std::str::FromStr, T3: std::str::FromStr>() -> (T1, T2, T3)
where T1::Err: std::fmt::Debug, T2::Err: std::fmt::Debug, T3::Err: std::fmt::Debug {
    let line = read_line();
    let mut splitted = line.split_whitespace();
    let v1: T1 = splitted.next().unwrap().parse().unwrap();
    let v2: T2 = splitted.next().unwrap().parse().unwrap();
    let v3: T3 = splitted.next().unwrap().parse().unwrap();
    (v1, v2, v3)
}

fn read4<T1: std::str::FromStr, T2: std::str::FromStr, T3: std::str::FromStr, T4: std::str::FromStr>() -> (T1, T2, T3, T4)
where T1::Err: std::fmt::Debug, T2::Err: std::fmt::Debug, T3::Err: std::fmt::Debug, T4::Err: std::fmt::Debug {
    let line = read_line();
    let mut splitted = line.split_whitespace();
    let v1: T1 = splitted.next().unwrap().parse().unwrap();
    let v2: T2 = splitted.next().unwrap().parse().unwrap();
    let v3: T3 = splitted.next().unwrap().parse().unwrap();
    let v4: T4 = splitted.next().unwrap().parse().unwrap();
    (v1, v2, v3, v4)
}

use std::cmp;
fn main() {
    let (a, b, c, d): (i32, i32, i32, i32)  = read4();

    let begin = cmp::max(a, c);
    let end = cmp::min(b, d);
    let mut time = end - begin;
    if time < 0 {
        time = 0;
    }
    println!("{}", time);
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
string S;
cin >> S;
if (S == "SUN")
    printf("7\n");
else if (S == "MON")
    printf("6\n");
else if (S == "TUE")
    printf("5\n");
else if (S == "WED")
    printf("4\n");
else if (S == "THU")
    printf("3\n");
else if (S == "FRI")
    printf("2\n");
else if (S == "SAT")
    printf("1\n");

}


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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var a = new List<long>();

            for (int i = 0; i < n; i++)
            {
                a.Add(long.Parse(Console.ReadLine()));
            }

            a.Sort();

            var count = 0;

            for (int i = 0; i < n; i++)
            {
                if (i == n - 1)
                {
                    count++;
                }
                else if (a[i] == a[i + 1])
                {
                    i++;
                }
                else
                {
                    count++;
                }
            }

            Console.WriteLine(count);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

string make_string(int p, int x){
  string left, right, a, b;
  a=to_string(p); b=to_string(x);
  rep(i,6-a.size()) left+='0';
  left+=a;
  rep(i,6-b.size()) right+='0';
  right+=b;
  return left+right;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<string> ans(m);
  vector<vector<P>> info(n+1);
  rep(i,m){
    int p, y;
    cin >> p >> y;
    p--;
    info[p].push_back(make_pair(y,i));
  }
  rep(i,n){
    if(info[i].size()==0) continue;
    sort(info[i].begin(),info[i].end());
    int tmp=0;
    for(auto x : info[i]){
      tmp++;
      string now = make_string(i+1,tmp);
      ans[x.second]=now;
    }
  }
  //answer
  rep(i,m){
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 11872
N = int(input())
nums = list(map(int, input().split()))
nums.sort()
checked = [0 for _ in range(nums[-1]+1)]
answer = 0
for i in range(N-1):
  if checked[nums[i]] == 1:
    continue
  else:
    if nums[i] != nums[i+1]:
      answer += 1
    count = 1
    temp = nums[i]
    while(temp <= nums[-1]):
      checked[temp] = 1
      count += 1
      temp= nums[i]*count
if checked[nums[-1]] == 0:
  answer += 1
print(answer)

Measured memory_bytes: 164304
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main() {
    int x,y;
    while(cin>>x>>y&&(x!=0||y!=0))
    {
        if(x<y)cout<<x<<" "<<y<<endl;
        else cout<<y<<" "<<x<<endl;
    }
    return 0;
}



Measured memory_bytes: 3032
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    s = input().rstrip()
    t = input().rstrip()

    if s in t and len(t) - len(s) == 1 and s[0] == t[0]:
        print("Yes")
    else:
        print("No")

#    print("n")


resolve()

Measured memory_bytes: 61656
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 土  9/ 8 21:51:51 2018

# Usage
#
"""
from fractions import gcd
from functools import reduce
def input_nlines_multi():
    initial_pos = int(input().split(" ")[1])
    poses = [int(i) for i in input().split(" ")]

    return [initial_pos, poses]

def get_each_GCD(initial_pos, poses):
    """
    >>> get_each_GCD(3, [1,7,11])
    2
    >>> get_each_GCD(81, [33,105,57])
    24
    >>> get_each_GCD(1, [1000])
    999
    """
    target_nums = [abs(p - initial_pos) for p in poses]

    return reduce(gcd, target_nums)

if __name__ == '__main__':
    # import doctest
    # doctest.testmod()
    print(get_each_GCD(*input_nlines_multi()))


Measured memory_bytes: 16268
#include<iostream>
#include<string>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
    int N, a = -1, b = -1;
    cin >> N;
    vector<int> A(N, 0), B(200000, 0);
    
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) ++B[A[i]];
    for (int i = 200000; i > 0; i--) {
        if (B[i] > 0 && a < 0) {
            a = i;
        }
        else if (B[i] > 0 && a >= 0) {
            b = i; break;
        }
    }

    for (int i = 0; i < N; i++) {
        if (A[i] != a)  cout << a << endl;
        else if (B[a] > 1) cout << a << endl;
        else cout << b << endl;
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
std::cin >>x>>y>>z;
if(x>z){
  std::cout << x-z<<" "<<y << '\n';
}else if(x+y-z>0){
  std::cout << 0<<" "<< x+y-z << '\n';
}else std::cout <<0<< " "<<0 << '\n';
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int const mxn=2e3+3;
int cnt[mxn];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n,x,y;
	cin >> n >> x >> y;
	if(x>y)swap(x,y);
	for(int i=1; i<=n; i++){
		for(int j=i+1; j<=n; j++){
			int dist = min(j-i,abs(x-i)+abs(y-j)+1);
			cnt[dist]++;
		}
	}
	for(int i=1; i<n; i++)cout << cnt[i] << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

#define ll long long int
#define endl "\n"
#define mod 1000000007

int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	{
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
	ll t;
	//cin >> t;
	t = 1;
	while (t--) {
		ll a, b, c, d, x, y;
		cin >> a >> b >> c >> d;
		if ( a % d == 0) {
			x = a / d;
		} else {x = (a / d) + 1;}
		if ( c % b == 0) {
			y = c / b;

		} else {y = (c / b) + 1;}
		if (y <= x) {
			cout << "Yes" << endl;
		} else {cout << "No" << endl;}
	}

	return 0;

}

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

int main()
{
	int n; cin>>n;
	double ans=0;
	double a;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		ans+=1.0/a;
	}
	cout<<fixed<<setprecision(10)<<(1.0/ans)<<endl;
	return 0;
}

Measured memory_bytes: 256
while line=gets
(m,f,r)=line.split().map(&:to_i)
  break if m==-1&&f==-1&&r==-1
  if m==-1 || f==-1 || (m+f < 30)
    puts "F"
  elsif m+f >= 80
    puts "A"
  elsif m+f >= 65 && m+f < 80
    puts "B"
  elsif m+f >= 50 && m+f < 65
    puts "C"
  elsif m+f >= 30 && m+f < 50
    puts r >= 50 ? "C" : "D"
  else
    puts "ERROR"
  end
end

Measured memory_bytes: 6104
N = int(input())
S = input()
ans = 0

for i in range(1, N):
    tmp = 0
    check_char_list = set(list(S[:i]))
    for item in set(list(S[i:])):
        if item in check_char_list:
            tmp += 1
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

bool ss(string s, string t){
	int k=0;
	fore(i,0,SZ(t)){
		if(t[i]==s[k])k++;
		if(k==SZ(s))return true;
	}
	return false;
}

int main(){
	string s;
	cin>>s;
	puts(ss(s,"AKIHABARA")&&ss("KIHBR",s)?"YES":"NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<long double> a(n);
    for (auto &x : a) {
        cin >> x;
    }
    sort(a.rbegin(), a.rend());
    for (int i = n - 1; i >= 1; i--) {
        a[i - 1] = (a[i - 1] + a[i]) / (long double) (2.0);
    }
    cout << a[0] << "\n";
}


Measured memory_bytes: 256
using Yorukatsu033.Questions;
using Yorukatsu033.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu033.Questions
{
    /// <summary>
    /// ABC120 A
    /// </summary>
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var abc = inputStream.ReadIntArray();
            yield return Math.Min(abc[1] / abc[0], abc[2]);
        }
    }
}

namespace Yorukatsu033
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu033.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu033.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=2000000000000000000;
constexpr int mod=998244353;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,m;string s;
vector<int>v;
vector<int>a;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m>>s;
    int nw=n;
    rep(i,n+1){
        if(s[i]=='0')v.pb(i);
    }
    while(1){
        if(nw==0)break;
        int lb=*lower_bound(all(v),nw-m);
        if(nw<=lb){
            puts("-1");
            return 0;
        }
        a.pb(nw-lb);
        nw=lb;
    }
    reverse(all(a));
    rep(i,a.size()){
        cout<<a[i];
        if(i==a.size()-1)cout<<endl;
        else cout<<" ";
    }
    return 0;
}



Measured memory_bytes: 2628
n=int(input())
inf=10*100
h=list(map(int,input().split()))+[inf]
n=len(h)
length=[0]*(n-1)+[1]
cnt=[]
move=0
for i in range(n-1):
    if h[i]<h[i+1]:
        length[i+1]=1
        if i==0:
            length[i]=1
for i in range(1,n):
    if length[i]==0:
        move+=1
    else:
        cnt.append(move)
        move=0
if len(cnt)==0:
    print(n-2)
else:
    print(max(cnt))

Measured memory_bytes: 14252
#include<iostream>
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define int long long
#define MOD 1000000007
#define PI 2*acos(0)
using namespace std;
int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n, a, b, ans = 0; cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		int ii = i, sum = 0;
		do {
			sum += ii % 10;
		} while (ii /= 10);
		if (a <= sum && sum <= b)
			ans += i;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
import fractions


def prime_factorization(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n = n // i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return list(set(table))


def main():
    a, b = map(int, input().split())

    gcd = fractions.gcd(a, b)
    table = prime_factorization(gcd)
    print(len(table) + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5088
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>

using namespace std;

// Returns 0 (Player 0 wins) or 1 (Player 1 wins)
int FindWinner(int W, int N, int sc, string S, string T, char L, char R)
{
  // player 1 wins if x in [left, right]
  int left = 1;
  int right = W;
  int pleft;
  int pright;

  for (int i = N - 1; i >= 0; --i) {
    // Player 1
    if (T[i] == L) {
      pleft = left;
      if (right != W) pright = right + 1;
      else pright = right;
    } else if (T[i] == R) {
      if (left != 1) pleft = left - 1;
      else pleft = left;
      pright = right;
    }
    else {
      pleft = left;
      pright = right;
    }
    swap(left, pleft);
    swap(right, pright);
    
    // Player 0
    if (S[i] == L) {
      pleft = left + 1;
      pright = right;
    } else if (S[i] == R) {
      pleft = left;
      pright = right - 1;
    }
    else {
      pleft = left;
      pright = right;
    }
    swap(left, pleft);
    swap(right, pright);
    if (left > right) return 0;
  }

  if (left <= sc and sc <= right) return 1;
  else return 0;
}

int main()
{
  int H, W, N;
  cin >> H >> W >> N;
  int sr, sc;
  cin >> sr >> sc;  // 1-origin coordinate
  string S, T;
  cin >> S;
  cin >> T;

  if (FindWinner(W, N, sc, S, T, 'L', 'R') == 0 or
      FindWinner(H, N, sr, S, T, 'U', 'D') == 0) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1544
#include <iostream>
#include <vector>
#include <set>
#include <unordered_map>
#include <algorithm>

#define ll long long
#define Inf 1000000001
using namespace std;


ll gcd(ll a, ll b) {
    while(b!=0) {
        ll t = b;
        b=a%b;
        a=t;
    }
    return a;
}

int main() {
    ll N;
    cin>>N;
    ll ansh,ansn,answ;
    bool found=false;
    for(int h=1;h<=3500;h++) {
        if (found)
            break;
        for(int n=1;n<=3500;n++) {
            if (found)
                break;
            ll numer = h+n;
            ll denom = h*n;
            
            // 4/N-numer/denom
            // 4*denom-N*numer
            
            ll numer2 = 4*denom-N*numer;
            if (numer2 < 0)
                continue;
            // h*n*N
            ll denom2 = h*n*N;
            ll g = gcd(numer2, denom2);
            
            
            numer2/=g;
            denom2/=g;
            
            if (numer2 == 1 && denom2 >= 1) {
                ansh = h;
                ansn = n;
                answ = denom2;
                found=true;
            }
        }
    }
    
    printf("%lld %lld %lld\n",ansh,ansn,answ);
}

Measured memory_bytes: 256