akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	REP(i,SZ(s)-1){
		if(s[i]=='A' && s[i+1]=='C'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//const int mod=(int)998244353;
const llint big=(llint)(2.19e16)+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
using pli=pair<llint,int>;
using daic=priority_queue<pli,vector<pli>,greater<pli>>;
int main(void){
	llint n,A,B,i,j;cin>>n>>A>>B;
	if(A*B<n){cout<<"-1\n";RE;}
	if(n+1<A+B){cout<<"-1\n";RE;}
	vector<llint>mae;//後で座圧する
	for(j=0;j<A;j++){mae.pub(A*(B-1)+j);}
	for(i=B-2;i>=0;i--){
		for(j=0;j<A;j++){
			if(j!=0&&(n-(int)mae.size())<=i){break;}
			mae.pub(A*i+j);
		}
	}
	vector<llint>atu=mae;
	SO(atu);
	for(i=0;i<n;i++){cout<<LBI(atu,mae[i])+1<<" ";}
	cout<<endl;
	RE;
}

Measured memory_bytes: 7916
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	long long int s;
	cin>>s;
	long long int t=ceil(sqrt(s));
	if(t*t==s){
		cout<<"0 0 0 "<<t<<" "<<t<<" 0"<<endl;
	}
	else{
		if((s-(t-1)*(t-1))>=(t*t-s)){
			cout<<"0 0 1 "<<t<<" "<<t<<" "<<t*t-s<<endl;
		}
		else {
			cout<<"1 0 0 "<<t-1<<" "<<t<<" "<<s-(t-1)*(t-1)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*

val sc = Scanner(System.`in`)
val A = mutableListOf<String>()
val B = mutableListOf<String>()
var N = 0
var M = 0

fun main(args: Array<String>) {
	N = sc.nextInt()
	M = sc.nextInt()

	for (i in 0 until N) {
		A.add(sc.next())
	}
	for (i in 0 until M) {
		B.add(sc.next())
	}
	for (i in 0 until N) {
		for (j in 0 until N) {
			if (judge(i, j)) {
				println("Yes")
				return
			}
		}
	}
	println("No")
}

fun judge(Ni: Int, Nj: Int): Boolean {
	for (i in 0 until M) {
		for (j in 0 until M) {
			when {
				Ni + i >= N || Nj + j >= N || B[i][j] != A[Ni + i][Nj + j]
				-> return false
			}
		}
	}
	return true
}



Measured memory_bytes: 29480
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	string S;
	long long K;
	cin >> S >> K;
	long long cnt1 = 0;
	long long cnt2 = 0;
	long long ans1 = 0;
	long long ans2 = 0;
	bool renzoku = false;

	if (S.length() == 1) {
		cout << K / 2; return 0;
	}

	for (int i = 1; i <= S.length() - 1; i++) {
		if (S[i] != S[0])break;
		if (i == S.length() - 1) { cout << S.length() * K / 2; return 0; }
	}

	for (int i = 1; i <= S.length() - 1; i++) {
		if (S[i] == S[i - 1]) {
			cnt1++; renzoku = true;
		}
		if (S[i] != S[i - 1] && renzoku == true) {
			ans1 += (cnt1 + 1) / 2;
			renzoku = false;
			cnt1 = 0;
		}
		if (i == S.length() - 1) {
			ans1 += (cnt1 + 1) / 2;
		}
	}

	renzoku = false;
	for (int i = 1; i <= S.length() - 1; i++) {
		if (S[i] == S[i - 1]) {
			cnt2++; renzoku = true;
		}
		if (S[i] != S[i - 1] && renzoku == true) {
			ans2 += (cnt2 + 1) / 2;
			renzoku = false;
			cnt2 = 0;
		}
	}
	for (int j = 0; j <= S.length() - 1; j++) {
		if (j == 0) {
			if (S[j] == S[S.length() - 1]) {
				cnt2++; renzoku = true;
			}
			if (S[j] != S[S.length() - 1] && renzoku == true) {
				ans2 += (cnt2 + 1) / 2;
				renzoku = false;
				cnt2 = 0;
			}
			continue;
		}
		if (S[j] == S[j - 1]) {
			cnt2++; renzoku = true;
		}
		if (S[j] != S[j - 1] && renzoku == true) {
			ans2 += (cnt2 + 1) / 2;
			renzoku = false;
			cnt2 = 0;
		}
		if (j == S.length() - 1) {
			ans2 += (cnt2 + 1) / 2;
		}
	}
	cout << ans1 + (ans2 - ans1) * (K - 1);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
    public static void main(String[] args) throws Exception{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int x = Integer.parseInt(br.readLine());
            System.out.println(x*x*x);
    }
}

Measured memory_bytes: 24292
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]


N = int(input())
A = list(map(int, input().split()))

B=[]
for i in range(N):
    B+=[[i+1,A[i]]]
B.sort(key=lambda x:x[1])

print(B[0][0], end="")
for i in range(1,N):
    print(" ", B[i][0], end="")

Measured memory_bytes: 96104
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;


int main() {
	int h, w, d; cin >> h >> w >> d;

	map<int,pair<int,int>> mp;

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			int a; cin >> a;
			mp[a] = make_pair(i, j);
		}
	}

	vector<int> ruiseki(h*w + 1, 0);

	for (int i = d + 1; i <= h * w; i++) {
		ruiseki[i]=ruiseki[i-d]+ abs(mp[i].first - mp[i-d].first) + abs(mp[i].second - mp[i-d].second);
	}

	int q; cin >> q;

	for (int i = 0; i < q; i++) {
		int l, r; cin >> l >> r;
		cout << ruiseki[r] - ruiseki[l] << endl;
	}



	return 0;
}

Measured memory_bytes: 7040
#include<iostream>
using namespace std;
#define PI 3.14159265358979323846264
int main() {
	while (true) {
		long double p; cin >> p; if (p == 0)break;
		for (long double i = 0; i < 20000000; i += 1) {
			long double q1 = (PI - p) * i;
			long double q2 = (PI + p) * i;
			int r1 = q1, r2 = q2;
			if (r1 < r2) {
				cout << r2 << '/' << (int)i << endl; break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}



int main(){
    string T,S;
    cin >> S >> T;
    cout << T << S <<endl;

    
}

Measured memory_bytes: 256
#include <stdio.h>

int calc_gcd(int a, int b);

int main(int argc, char *argv[])
{
	int a, b;
	while (scanf("%d %d", &a, &b) != -1) {
		int gcd, lcm;
		gcd = calc_gcd(a, b);
		lcm = a / gcd * b;
		printf("%d %d\n", gcd, lcm);
	}
	return 0;
}

int calc_gcd(int a, int b)
{
	int m;
	while (b) {
		m = a % b;
		a = b;
		b = m;
	}
	return a;
}

Measured memory_bytes: 596
import java.io.PrintWriter
import java.util.*

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val S = next()
    val T = next()
    val dictS = HashMap<Char, Char>()
    val dictT = HashMap<Char, Char>()
    for (i in S.indices) {
        val s = S[i]
        val t = T[i]
        if ((dictS.containsKey(s) && dictS[s] != t) || dictT.containsKey(t) && dictT[t] != s) {
            println("No")
            return
        }
        dictS[s] = t
        dictT[t] = s
    }
    println("Yes")
}

Measured memory_bytes: 36972
#pragma GCC optimize "O3"
  
#define F first
#define S second
#define G0(x) get<0>(x)
#define G1(x) get<1>(x)
#define G2(x) get<2>(x)
  
#include <bits/stdc++.h>
  
using namespace std;
  
typedef pair<int, int> PII;
typedef tuple<int, int, int> PIII;
  
constexpr int N = 3000, M = 300, INF = INT_MAX;
  
int n, m, cap, dis[2*N+2];
unordered_map<string, int> sid;
vector<PII> adj[2*N+2];
bool is_lpg[2*N+2];
  
inline void init() {
  sid.clear();
  cap *= 10;
  memset(is_lpg, 0, sizeof(is_lpg));
}
  
inline int solve() {
  init();
  string s0, s1;
  cin >> s0 >> s1;
  sid.emplace(s0, 0);
  adj[0].clear();
  sid.emplace(s1, 1);
  adj[1].clear();
  for(int i = 0; i<n; ++i) {
    int d;
    cin >> s0 >> s1 >> d;
    if(!sid.count(s0)) {
      adj[sid.size()].clear();
      sid.emplace(s0, sid.size());
    }
    if(!sid.count(s1)) {
      adj[sid.size()].clear();
      sid.emplace(s1, sid.size());
    }
    int id0 = sid[s0], id1 = sid[s1];
    adj[id0].emplace_back(id1, d);
    adj[id1].emplace_back(id0, d);
  }
  is_lpg[0] = is_lpg[1] = true;
  for(int i = 0; i<m; ++i) {
    cin >> s0;
    is_lpg[sid[s0]] = true;
  }
  int mid = sid.size();
  //cerr << "# nodes = " << mid << endl;
  fill(dis, dis+mid, INF);
  dis[0] = 0;
  priority_queue<PII, vector<PII>, greater<PII>> pq0;
  pq0.emplace(0, 0);
  while(!pq0.empty()) {
    PII nxt0 = pq0.top(); pq0.pop();
    //cerr << "cost " << nxt0.F << " id " << nxt0.S << endl;
  
    vector<int> tmp_dis(mid, INF);
    tmp_dis[nxt0.S] = nxt0.F;
    priority_queue<PIII, vector<PIII>, greater<PIII>> pq1;
    pq1.emplace(nxt0.F, cap, nxt0.S);
    while(!pq1.empty()) {
      PIII nxt1 = pq1.top(); pq1.pop();
      for(auto &v : adj[G2(nxt1)])
        if(G1(nxt1) >= v.S && G0(nxt1) + v.S < tmp_dis[v.F]) {
          tmp_dis[v.F] = G0(nxt1) + v.S;
          pq1.emplace(tmp_dis[v.F], G1(nxt1)-v.S, v.F);
        }
    }
    for(int i = 0; i<mid; ++i)
      if(is_lpg[i] && tmp_dis[i] < dis[i]) {
        dis[i] = tmp_dis[i];
        pq0.emplace(dis[i], i);
      }
  }
  if(dis[1] == INF)
    return -1;
  else
    return dis[1];
}
  
int main() {
  while(scanf("%d %d %d", &n, &m, &cap) == 3 && n)
    printf("%d\n", solve());
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
#define outc cout
#define int long long
signed main(){
  int b=0,f=0,g=0,c;
  string a;
  cin>>a;
  c=a.size();
  for(int i=0;i<a.size();i++){
    if(a[i]=='S') b++;
    if(b&&a[i]=='T') b--,c-=2;
  }
  cout<<c<<"\n";}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
nums = map(int, input().split())
MOD = 1000000007
ans = 1
cnt = [3 if i == 0 else 0 for i in range(N + 1)]

# print(cnt)

for num in nums:
    ans = ans * cnt[num] % MOD
    if ans == 0:
        break
    cnt[num] -= 1
    cnt[num + 1] += 1
# print(cnt)
print(ans)


Measured memory_bytes: 54572
S = gets.chomp.tr("?",".")
T = gets.chomp

puts (0..S.size-T.size).map{ |k|
  s = S[k...k+T.size]
  #$stderr.puts [k,s]
  next nil if !T.match(Regexp.new(s))
  
  t = (S[0...k]+T+S[k+T.size..-1]).tr(".","a")
  #$stderr.puts t
  t
}.compact.min || "UNRESTORABLE"

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);

//		int N = scanner.nextInt();
//
//		int K = scanner.nextInt();

		int N = scanner.nextInt();

		int ans=0;
		int max=0;

		int[] arrayH = new int[N];

		for(int index = 0; index < N; index++) {
			arrayH[index] = scanner.nextInt();
		}

		for (int index = 1; index < N; index++) {

			if(arrayH[index - 1] >= arrayH[index]) {
				max++;
				if(ans < max) {
					ans = max;
				}
			} else {
				max =0;
			}
		}


		log(ans);

//		int[] scannerArray = new int[N];
//
//		for (int index = 0; index < N; index++) {
//			scannerArray[index] = scanner.nextInt();
//		}
//
//		int tmp = countSwapBabbleSort(scannerArray);
//
//		log((
//				(BigInteger.valueOf((long)tmp)
//				.multiply(BigInteger.valueOf((long)K)
//						))
//				.add((
//						BigInteger.valueOf((long)tmp)
//						.multiply(
//								BigInteger.valueOf((long)K)
//								.multiply(
//										BigInteger.valueOf((long)K)
//										.subtract(BigInteger.ONE)
//										)
//								.divide(BigInteger.valueOf((long)2)
//										)
//								)
//						)))
//				.remainder(
//						BigInteger.valueOf((long)1000000007)
//						)
//				.toString());
	}


	/**
	 * バブルソートの交換数を算出
	 * ※転倒数
	 * @param array
	 * @return
	 */
	private static int countSwapBabbleSort(int[] array) {
		int ans = 0;
		int[] binary = new int[array.length + 1];

		for (int index = 0; index < array.length; index++) {
			ans = ans + (index - sum(binary, array[index]));
			add(binary, array[index], 1);
		}
		return ans;
	}

    //add value at idx on bit O(logN)
	private static void add(int[] bit,int idx,int value) {
        for(int i=idx;i<bit.length;i=i+(i&-i)) {
        	bit[i] += value;
        }
    }

    //return sum [1,idx] O(logN)
	private static int sum(int[] bit,int idx) {
        int ret = 0;
        for(int i=idx;i>0;i-=(i&-i)) {
        	ret += bit[i];
        }
        return ret;
    }

	private static void log(String str) {
		System.out.println(str);
	}

	private static void log(int str) {
		System.out.println(str);
	}

	private static void log(double str) {
		System.out.println(str);
	}

}



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

using namespace std;


int main(){
 string s, t;
cin>>s>>t;

string kotae(s.size(),'z');
int ikai=0;

 for(int i=0;i<s.size()-t.size()+1;i++){
bool issyo=true;

for(int j=i;j<i+t.size();j++){
  if(s[j]!=t[j-i] && s[j]!='?') {
issyo=false;
break;}
}

if(issyo){
for(int k=i;k<i+t.size();k++){
kotae[k]=t[k-i];}
for(int q=0;q<i;q++){
if(s[q]=='?') kotae[q]='a';
else kotae[q]=s[q];}
for(int q=i+t.size();q<s.size();q++){
if(s[q]=='?') kotae[q]='a';
else kotae[q]=s[q];}
ikai=1;
}
}
 
if(ikai){
 cout<<kotae<<endl;}
else{
cout<<"UNRESTORABLE"<<endl;}



 
}
 

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

int main()
{
    string S;
    cin >> S;
    int N = S.size();
    vector<long long> v(2019, 0);
    long long fac = 1;
    long long current = 0;
    v[current]++;
    for (int i = 0; i < N; i++)
    {
        long long d = S[N - 1 - i] - '0';
        current = (current + fac * d) % 2019;
        fac = (fac * 10) % 2019;
        v[current]++;
    }
    long long res = 0;
    for (int i = 0; i < 2019; i++)
    {
        res += v[i] * (v[i] - 1) / 2;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3724
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static boolean doNim(final int all, int player, int[] M, int S, boolean[][] is_memo, boolean[][] memo){
		//System.out.println((player % 2 == 0 ? "Your  Team" : "Enemy Team") + " : " + (player / 2 + 1) + "th" + " => "+ S);
		if(is_memo[S][player]){
			return memo[S][player];
		}else if(S == 0){
			is_memo[S][player] = true;
			return memo[S][player] = true;
		}
		
		boolean can_win = false;
		for(int use = M[player]; use >= 1; use--){
			if(!doNim(all, (player + 1) % all, M, Math.max(0, S - use), is_memo, memo)){
				can_win = true;
				break;
			}
		}
		
		is_memo[S][player] = true;
		return memo[S][player] = can_win;
	}
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			final int all = n * 2;
			
			if(n == 0){
				break;
			}
			
			final int S = sc.nextInt();
			int[] M = new int[all];
			for(int i = 0; i < all; i++){
				M[i] = sc.nextInt();
			}
			
			boolean[][] is_memo = new boolean[S + 1][all];
			boolean[][] memo = new boolean[S + 1][all];
			System.out.println(doNim(all, 0, M, S, is_memo, memo) ? 1 : 0);
			
			System.gc();
		}
		
		
		sc.close();
	}

	public static class Scanner {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			if (tok == null) {
				return false;
			} else {
				return tok.hasMoreTokens();
			}
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public void close() throws IOException {
			br.close();
		}
	}

}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char> > a(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a.at(i).at(j);
    }
  }
  for (int i = h-1; i >= 0; i--) {
    if (a.at(i) == vector<char>(w, '.')) {
      a.erase(a.begin() + i);
    }
  }
  bool emptyColumn = true;
  for (int i = w-1; i >= 0; i--) {
    for (int j = 0; j < a.size(); j++) {
      if (a.at(j).at(i) == '#') {
        emptyColumn = false;
        break;
      }
    }
    if (emptyColumn) {
      for (int j = 0; j < a.size(); j++) {
        a.at(j).erase(a.at(j).begin() + i);
      }
    }
    emptyColumn = true;
  }

  h = a.size();
  w = a.at(0).size();

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << a.at(i).at(j);
      if (j == w-1) {
        cout << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[100001];
	cin>>a;
	for(int i=0;i<=strlen(a)-1;++i){
		if(a[i]=='C'){
			for(int j=i;j<=strlen(a)-1;++j){
				if(a[j]=='F'){
					cout<<"Yes";return 0;
				} 
			}
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <math.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string n;
    cin >> n;
    string res = "ABC" + n;

    cout << res << endl;
    return 0;    
}



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

int n, k, num = 0;
vector<int> a;

int solve();

int main() {
  cin >> n >> k;
  a.resize(n);
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    if(a[i] == 1) num = i;
  }
  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = 0, now = 0;
  ans = num / (k - 1);
  now = num % (k - 1);
  num = n - 1 - num;
  ans += num / (k - 1);
  now += num % (k - 1);
  ans += (now + k - 2) / (k - 1);
  return ans;
}

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

using namespace std;

template <typename T>
struct DCA{
    vector<vector<pair<T,int> > > path;
    int n;

    DCA(int n_){
        n = n_;
        path.resize(n);
    }

	void add_path(int s,int e){
		path[s].push_back(make_pair(1,e));
	}
	void add_path(T d,int s,int e){
		path[s].push_back(make_pair(d,e));
	}

	vector<int> topologicalsort(){
	    int i,j,k;
	    vector<int> d(n,0),r(n,-1);
	    for(i = 0;i < n;i++){
            for(j = 0;j < path[i].size();j++){
                d[path[i][j].second]++;
            }
	    }
	    k = 0;
	    for(i = 0;i < n;i++){
            if(d[i] == 0){
                r[k++] = i;
            }
	    }
	    for(i = 0;i < n;i++){
            if(r[i] == -1){ //detect error
                return vector<int>();
            }
            for(j = 0;j < path[r[i]].size();j++){
                d[path[r[i]][j].second]--;
                if(d[path[r[i]][j].second] == 0){
                    r[k++] = path[r[i]][j].second;
                }
            }
	    }
	    return r;
	}
};

int n,m;

void solve(){
    int i,j;
    cin >> n >> m;
    DCA<int> dca(n);
    for(i = 0;i < m;i++){
        int x,y;
        cin >> x >> y;
        x--;y--;
        dca.add_path(x,y);
    }
    vector<int> ts = dca.topologicalsort();
    vector<int> dp(n,0);
    for(i = 0;i < n;i++){
        for(j = 0;j < dca.path[ts[i]].size();j++){
            dp[dca.path[ts[i]][j].second] = max(dp[dca.path[ts[i]][j].second],dp[ts[i]]+1);
        }
    }
    int ans = 0;
    for(i = 0;i < n;i++) ans = max(ans,dp[i]);
    cout << ans << endl;
}

int main(){
    solve();
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n;
ll a[100005];
ll g1[100005], g2[100005];

ll gcd(ll a, ll b)
{
	if (a < b) gcd(b, a);
	ll r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;

}

int main() {
	std::cin >> n;
	for (int i = 0; i < n; ++i)
		std::cin >> a[i];

	g1[0] = a[0];
	for (int i = 1; i < n; ++i)
		g1[i] = gcd(g1[i - 1], a[i]);

	g2[n - 1] = a[n - 1];
	for (int i = n - 2; i >= 0; --i)
		g2[i] = gcd(g2[i + 1], a[i]);

	ll ans = std::max(g1[n - 2], g2[1]);
	for (int i = 2; i < n; ++i)
		ans = std::max(ans, gcd(g1[i - 2], g2[i]));

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


Measured memory_bytes: 2560
N = input()[::-1]

dp1 = [0]
dp2 = [1]

for x in N:
    x = int(x)

    r = dp1[-1]+x
    if x<9: r = min(r, dp2[-1]+x+1)
    dp1.append(r)
    dp2.append(min(dp1[-2]+10-x, dp2[-1]+9-x))

print(min(dp1[-1],dp2[-1]+1))

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

int main() {
  int64_t N, C;
  int64_t kcal_max = numeric_limits<int64_t>::min();
  cin >> N >> C;
  vector<int64_t> x(N + 2), v(N + 2);
  for (int i = 1; i <= N; ++i) {
    cin >> x[i];
    cin >> v[i];
  }
  vector<int64_t> v_right = v;
  for (int i = 2; i <= N; ++i) v_right[i] += v_right[i - 1];
  vector<int64_t> f_right = v_right;
  for (int i = 1; i <= N; ++i) f_right[i] -= x[i];
  vector<int64_t> g_right = f_right;
  for (int i = 1; i <= N; ++i) {
    g_right[i] = max(g_right[i - 1], g_right[i]);
    kcal_max = max(kcal_max, g_right[i]);
  }
  
  vector<int64_t> v_left = v;
  for (int i = N - 1; i >= 1; --i) v_left[i] += v_left[i + 1];
  vector<int64_t> f_left = v_left;
  for (int i = 1; i <= N; ++i) f_left[i] -= C - x[i];
  vector<int64_t> g_left = f_left;
  for (int i = N; i >= 0; --i) {
    g_left[i] = max(g_left[i], g_left[i + 1]);
    kcal_max = max(kcal_max, g_left[i]);
  }
  
  for (int a = 0; a < N - 1; ++a) {
    const int64_t kcal = v_right[a] - 2 * x[a] + g_left[a + 1];
    kcal_max = max(kcal_max, kcal);
  }
  for (int b = 1; b <= N; ++b) {
    const int64_t kcal = v_left[b] - 2 * (C - x[b]) + g_right[b - 1];
    kcal_max = max(kcal_max, kcal);
  }
  cout << kcal_max << endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include <climits>

using namespace std;

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

	int Rmin, inputVal, maxProfit;
	maxProfit = INT_MIN;

	cin >> Rmin;
	for(int i = 1; i < n; ++i){
		cin >> inputVal;
		if(maxProfit < inputVal - Rmin){
			maxProfit = inputVal - Rmin;
		}
		if(Rmin > inputVal){
			Rmin = inputVal;
		}
	}

	cout << maxProfit << endl;

	return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<algorithm>
#include<string>
#include<cctype>
#define rep(i,n) for((i)=0;(i)<(n);i++)

using namespace std;

int v[3],n;
string s;

int f(){
  n++;
  if(s[n-1]=='('){
    int res=f();
    n++;
    if(s[n-1]=='+')res=max(res,f());
    if(s[n-1]=='*')res=min(res,f());
    n++;
    return res;
  }
  if(isdigit(s[n-1]))return s[n-1]-'0';
  if(isupper(s[n-1]))return v[s[n-1]-'P'];
  if(s[n-1]=='-')return 2-f();
}

int main(){
  while(cin >> s,s!="."){
    int cnt=0;
    rep(v[0],3)rep(v[1],3)rep(v[2],3)n=0,cnt+=f()/2;
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  ll k[100][100];
  rep(i,100){
    rep(j,100){
      k[i][j]=0;
    }
  }
  rep(i,n){
    string a;
    cin >> a;
    int z=0;
    rep(j,a.size()){
      if(a[j]=='.')z=z+1+j;
    }
    if(z==0){
      ll b=0;
      rep(j,a.size()){
        b*=10;
        b+=(a[j]-'0');
      }
      int c=50,d=50;
      while(b%2==0){
        c++;
        b/=2;
      }
      while(b%5==0){
        d++;
        b/=5;
      }
      k[c][d]++;
    }
    else{
      int r=a.size()-z;
      ll b=0;
      rep(j,a.size()){
        if(a[j]=='.')continue;
        b*=10;
        b+=(a[j]-'0');
      }
      int c=50-r,d=50-r;
      while(b%2==0){
        c++;
        b/=2;
      }
      while(b%5==0){
        d++;
        b/=5;
      }
      k[c][d]++;
    }
  }
  ll ans=0;
  ll kk[101][101];
  rep(i,100){
    rep(j,100){
      kk[i][j]=k[i][j];
    }
  }
  rep(i,101){
    kk[100][i]=0;
    kk[i][100]=0;
  }
  rep(i,100){
    rep(j,100){
      int x=100-1-i;
      int y=100-1-j;
      kk[x][y]+=(kk[x+1][y]+kk[x][y+1]-kk[x+1][y+1]);
    }
  }
  rep(i,100){
    rep(j,100){
      /*if(k[i][j]*kk[100-i][100-j]>0){
        cout << i << " " << j << " " << k[i][j] << " " << kk[100-i][100-j] << endl; 
      }*/
      
      ans+=k[i][j]*kk[100-i][100-j];
    }
  }
  cout << (ans-kk[50][50])/2 << endl;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
//#define INF  (1<<30)
#define INFL (1LL<<60)
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
#define ARR(...) vector<int>({__VA_ARGS__})
#define ARS(...) vector<string>({__VA_ARGS__})
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> base;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    os << '[';
    for (auto p : v) os << p << ",";
    os << "]";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
    os << "{";
    for (auto p : v) os << p << ",";
    os << "}";
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const multiset<T, V> &v) {
    os << "{";
    for (auto p : v) os << p << ",";
    os << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    os << "{";
    for (auto p : v) os << p << ",";
    os << "}";
    return os;
}
 
ostream& operator<<(ostream &os, tuple<int, int, int> t) {
    os << "<" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ">";
    return os;
}
 
#ifdef ONLINE_JUDGE
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
auto x = []{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    return 0;
}();

template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int main(void) { 
    int H, N; cin >> H >> N;
    rep(i, N) {
        int t; cin >> t;
        H -= t;
        if (H <= 0) {
            return cout << "Yes" << endl,0;
        }
    }
    cout << "No" << endl;
}




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

using namespace std;
using ll = long long;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

int main() {
	int N; cin >> N;
	for(int x = 111;x <= 999; x+=111){
		if(x>=N){
			cout << x << endl;
			return 0;
		}
	}

	return 0;
}



Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

import numpy as np

MOD = 10**9 + 7

N = int(readline())
H = [int(x) for x in readline().split()]

# 「初の同色」の位置によって場合分け。座圧して、近い区間のものは和をまとめて持つようにする。

H_unique = sorted(set([0,1]+H))
H_to_I = {h:i for i,h in enumerate(H_unique)}

items = [0] + [y-x for x,y in zip(H_unique,H_unique[1:])]

inv = pow(2,MOD-2,MOD)
coef = np.array([(pow(2,x+1,MOD)-2) * pow(inv,h,MOD) % MOD for x,h in zip(items,H_unique)],np.int64)

dp = np.zeros(len(H_unique),np.int64)
dp[0] = 1
I1,H1 = 1,1
for H2 in H:
    I2 = H_to_I[H2]
    prev = dp
    dp = np.zeros_like(prev)
    if I1 < I2:
        dp[0] = 2*prev[0]
        dp[1:I1+1] = prev[1:I1+1] * pow(2,H2-H1,MOD)
        dp[I1+1:I2+1] = coef[I1+1:I2+1] * pow(2,H2,MOD) % MOD * prev[0] % MOD
    else:
        prev[0] += prev[I2+1:].sum()
        dp += prev
        dp[0] *= 2
        dp[I2+1:] = 0
    dp %= MOD
    I1,H1 = I2,H2

answer = dp.sum()%MOD
print(answer)

Measured memory_bytes: 12428
import sys
sys.setrecursionlimit(10**8)
N = int(input())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for i in range(N)]
for i,(a,b) in enumerate(AB):
    a,b = a-1,b-1
    es[a].append((b,i))
    es[b].append((a,i))

visited = [0]*N
ans = [None]*(N-1)

def dfs(v,c=-1):
    nc = 1
    for to,i in es[v]:
        if visited[to]: continue
        visited[v] = 1
        if nc==c:
            nc += 1
        ans[i] = nc
        dfs(to,nc)
        nc += 1
dfs(0)
print(max(ans))
print(*ans,sep='\n')

Measured memory_bytes: 93960
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL gcd(LL a,LL b){
	LL t;
	if(a<b) swap(a,b); 
	while(b>0){
		t=a%b;
		a=b;
		b=t;
	}
	return a;
}
int main()
{
	int t;
	cin>>t;
	LL arr[105];
	for(int i=0;i<t;i++){
		cin>>arr[i];
	}
	for(int i=1;i<t;i++){
		LL temp=gcd(arr[i-1],arr[i]);
		arr[i]=arr[i-1]*(arr[i]/temp);
	}
	cout<<arr[t-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $S);
$a = array_map('intval', array_reverse(str_split($S)));
$len = strlen($S);
$x[0] = 0;
for ($i = 0; $i < $len; $i++) {
    if ($i === 0) {
        $b = 1;
    } else {
        $b = ($b * 10) % 2019;
    }
    $x[$i + 1] = ($b * $a[$i] + $x[$i]) % 2019;
}
$y = array_count_values($x);
$ans = 0;
foreach ($y as $dummy => $v) {
    $ans += $v * ($v - 1) / 2;
}
printf("%d", $ans);


Measured memory_bytes: 35648
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    for i in range(1, 10):
        for j in range(1, 10):
            if i * j == N:
                print('Yes')
                exit()
    else:
        print('No')


if __name__ == '__main__':
    main()


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<int> cost(m), can(m);
	for(int i = 0; i < m; i++) {
		int k;
		cin >> cost[i] >> k;
		for(int j = 0; j < k; j++) {
			int x;
			cin >> x;
			x--;
			can[i] |= 1<<x;
		}
	}
	
	vector<int> dp(1<<n, 1000*1000);
	dp[0] = 0;
	for(int i = 0; i < m; i++) {
		for(int s = 0; s < (1<<n); s++) {
			dp[s | can[i]] = min(dp[s | can[i]], dp[s] + cost[i]);
		}
	}
	
	if(dp[(1<<n)-1] == 1000*1000) dp[(1<<n)-1] = -1;
	cout << dp[(1<<n)-1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iterator>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(v) begin(v), end(v)
#define rreps(i, a, n) for (ll i = (a); i <= (ll)(n); ++i)
#define rrep(i, n) rreps(i, 0, n)
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define each(i, n) for (auto&& i : n)
#define fill(x, y) memset(x,y,sizeof(x))
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <typename T> inline void print(const T& x) {cout << x << '\n';}

signed main()
{ 
  int n;
  vi ans;
  while(cin>>n, n)
  {
    vi num(1001);
    num[0]=0;
    rreps(i,1,1000)
    {
      num[i]+=num[i-1]+i;
    }
    int cnt=0;
    rreps(i,1,1000)
    {
      reps(j,0,i-1)
      {
        if(n==num[i]-num[j]) cnt++;
      }
    }
    ans.pb(cnt);
  }
  each(v,ans) print(v);

  return 0;
}



Measured memory_bytes: 3116
import javax.swing.DefaultBoundedRangeModel

import scala.annotation.tailrec
import scala.collection.mutable

object Main extends App {
  import scala.io.StdIn._
  val MOD = 1000000007L
  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  val sqrt = math.sqrt(n).toInt
  val memo = Array.fill(k){Array.fill(sqrt + 1){-1L}}
  val invMemo = Array.fill(k){Array.fill(sqrt + 1){-1L}}
  for (i <- 1 until k) {
    for (j <- 1 to sqrt) solve(i, j, false)
    for (j <- 0 until sqrt) solve(i, sqrt - j, true)
  }
  println(solve(k - 1, 1, true))
  def solve(pos: Int, value: Int, inverse: Boolean = false): Long = {
    if (pos == 0 && !inverse) value
    else if (pos == 0) n / value
    else if (!inverse && memo(pos)(value) >= 0) memo(pos)(value)
    else if (inverse && invMemo(pos)(value) >= 0) invMemo(pos)(value)
    else if (inverse) {
      var result = count(value) * solve(pos - 1, value, false) % MOD
      result += (if (value == sqrt) solve(pos, sqrt, false) else solve(pos, value + 1, true))
      invMemo(pos)(value) = result % MOD
      result % MOD
    }else {
      var result = solve(pos - 1, value, true) % MOD
      result += (if (value == 1) 0 else solve(pos, value - 1, false))
      memo(pos)(value) = result % MOD
      result % MOD
    }
  }
  def count(value: Int): Int = {
    if (n / (value + 1) <= sqrt) n / value - sqrt
    else n / value - n / (value + 1)
  }
}

Measured memory_bytes: 93508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll dp[105][4][4][4],n;
ll func(ll len,ll i,ll j,ll k){
    if(i==0&&j==1&&k==2)return 0;
    if(i==0&&j==2&&k==1)return 0;
    if(i==2&&j==0&&k==1)return 0;
    if(len==n)return 1;

    ll &ans = dp[len][i][j][k];
    if(ans!=-1)return ans;

    ans=0;
    for(ll l=0;l<4;l++){
        if(i==0&&k==2&&l==1)continue;
        if(i==0&&j==2&&l==1)continue;
        ans+=func(len+1,j,k,l);
        ans%=mod;
    }
    return ans;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    memset(dp,-1,sizeof(dp));
    ll ans = 0;
    for(ll i=0;i<4;i++)for(ll j=0;j<4;j++)for(ll k=0;k<4;k++)ans+=func(3,i,j,k),ans%=mod;
    cout<<ans;
}

Measured memory_bytes: 256
// Gaurav Nuti
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define ar array
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define INF 1e9 

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

ll power_without_mod(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1;
        x = (x*x); 
    } 
    return res; 
}

bool comparep(pair<ll, ll> i1, pair<ll, ll> i2){
	return (i1.S < i2.S);
} 

ll modInverse(ll a)
{
    return power(a , mod - 2);
}

vector<vector<ll>> graph;
vector<bool> visited;
vector<ll> dist;
map<ll,ll> mymap;
ll max_dist = 1;

void bfs(int u1){
    visited[u1] = 1;
    dist[u1] = 1;
    mymap[1] = u1;
    queue<ll> q;
    q.push({u1});
    while(!q.empty()){
        ll u = q.front();
        q.pop();
        for(auto i=graph[u].begin();i!=graph[u].end();i++){
            if(!visited[*i]){
                dist[*i] = dist[u] + 1;
                visited[*i] = 1;
                max_dist = max(dist[*i],max_dist);
                mymap[dist[*i]] = *i;
                q.push({*i});
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    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;
    for(ll z=0;z<t;z++){
        ll n, k;
        cin>>n>>k;
        ll sum = 0;
        for(ll i=k; i<=n;i++){
            sum += ((n+1-i)%mod)*(i%mod) + 1;
            sum %= mod;
            // cout<<i<<" "<<(n+1-i)*i + 1<<"\n";
        }
        cout<<(sum+1)%mod;
    }
}

Measured memory_bytes: 3648
#include <stdio.h>
int main()
 {
 
	unsigned long long n,i,j;
	scanf("%llu",&n);
	unsigned long long a[n];
	for(i=0;i<n;i++)scanf("%llu",&a[i]);
	for(j=0;;j++)
    {
        for(i=0;i<n;i++)
        {
                  if(a[i]%2==0)a[i]=a[i]/2;
            else if(a[i]%2!=0)
            {
                printf("%llu\n",j);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 1684
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int ds(int k) {
  int res = 0;

  while (k > 0) {
    int take = k % 10;
    res += take;
    k /= 10;
  }

  return res;
}

bool between(int n, int a, int b) {
  return a <= n && n <= b;
}

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

  cin >> n >> a >> b;

  int total = 0;
  for (int i = 1; i <= n; ++i) {
    if (between(ds(i), a, b)) {
      total += i;
    }
  }

  cout << total << endl;
  return 0;
}


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

int main(){
	int a, b, c, x;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> x;

	int count = 0;
	for(int i=0; i<a+1; i++){
		//if(500*i > x){break;}
		for(int j=0; j<b+1; j++){
			//if(500*i+100*j > x){break;}
			for(int k=0; k<c+1; k++){
				if(i*500+j*100+k*50 == x){count++;}
				//if(i*500+j*100+k*50 > x){break;}
			}
		}
	}
	cout << count << endl;	
	return 0;
}


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

using namespace std;

void test_case()
{
int cnt=0;
string s,t;
cin>>s;
cin>>t;
//vector<char> a;
int l=s.length();
for(int i=0;i<l;++i)
{
if(s[i]!=t[i])
{
//a.push_back(s[i]);
cnt++;
}
}
/*sort(a.begin(),a.end());
vector<char>::iterator it;
it=unique(a.begin(),a.end());
a.resize(distance(a.begin(),it));
cout<<a.size()<<"\n";
*/
cout<<cnt<<"\n";
}
int main()
{
test_case();
return 0;
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int count(ll x){
	int cnt = 0;
	while(x != 0){
		cnt++;
		x /= 10;
	}
	return cnt;
}
vector< pair< int , int > > st(100) , ch(100);
vector< int > ans(100);
int main()
{
	string a , b;
	cin >> a >> b;
	if(a.size() > b.size())
		cout << "GREATER";
	else if(b.size() > a.size())
		cout << "LESS";
	else {

		if(a > b)
			cout << "GREATER";
		else if(b > a)
			cout << "LESS";
		else 
			cout << "EQUAL";
		
	}
}



Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
x = list(input())
xn = "1"
c = 0
y = []
for n in range(N):
    if x[n] == xn:
        c += 1
    else:
        xn = x[n]
        y.append(c)
        c = 1
y.append(c)
if len(y) % 2 == 0:
    y.append(0)
y = np.array(y)
l = 2 * K + 1
if l >= len(y):
    print(np.sum(y))
else:
    z = [np.sum(y[2 * i:2 * i + l]) for i in range((len(y) + 3 - l) // 2)]
    print(max(z))

Measured memory_bytes: 20392
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PI 3.1415926535

int main() {
    ll n, k;
    string s;
    cin >> n >> k >> s;
    k -= 1;
    if(s[k] == 'A') s[k] = 'a';
    else if(s[k] == 'B') s[k] = 'b';
    else if(s[k] == 'C')s[k] ='c';
    cout << s << endl;

}


Measured memory_bytes: 256
def is_fly(k,a,b):
  for i in range(a,b+1):
    if(i % k == 0):
      return True
  return False

k = int(input())
a,b = (int(x) for x in input().split())
if(is_fly(k,a,b)):
  print("OK")
else:
  print("NG")


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<vector<int>> v(10, vector<int>(10));
  rep1 (i, n) {
    string s = to_string(i);
    ++v[s.front() - '0'][s.back() - '0'];
  }
  int sum = 0;
  rep1 (i, 9) {
    rep1 (j, 9) {
      sum += v[i][j] * v[j][i];
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256