akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int h, w, k;
string s[300];
int a[300][300];

signed main() {
	int i, j;
	
	cin >> h >> w >> k;
	rep(i, h) cin >> s[i];
	
	vector<int> hs;
	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == '#') break;
		}
		if (j < w) {
			hs.push_back(i);
		}
	}
	hs.push_back(h);
	
	int val = 1;
	rep(i, hs.size() - 1) {
		vector<int> ws;
		rep(j, w) {
			if (s[hs[i]][j] == '#') ws.push_back(j);
		}
		ws.push_back(w);
		
		rep(j, ws.size() - 1) {
			//cout << "i = " << i << ", j = " << j << ", h[i] = " << hs[i] << ", w[j] = " << ws[j] << endl;
			if (j == 0) {
				for (int x = 0; x < ws[j + 1]; x++) {
					if (i == 0) {
						for (int y = 0; y < hs[i + 1]; y++) {
							a[y][x] = val;
						}
					}
					else {
						for (int y = hs[i]; y < hs[i + 1]; y++) {
							a[y][x] = val;
						}
					}
				}
			}
			else {
				for (int x = ws[j]; x < ws[j + 1]; x++) {
					if (i == 0) {
						for (int y = 0; y < hs[i + 1]; y++) {
							a[y][x] = val;
						}
					}
					else {
						for (int y = hs[i]; y < hs[i + 1]; y++) {
							a[y][x] = val;
						}
					}
				}
			}
			val++;
		}
	}
	
	rep(i, h) {
		rep(j, w) {
			cout << a[i][j];
			if (j + 1 < w) cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

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()
{
    int N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;

    ll l = lcm(N, M);
    int n = l / M;
    int m = l / N;

    int nn = 0;
    int mm = 0;
    bool flag = true;
    while (flag) {
        if (nn >= N || mm >= M) break;
        if (S[nn] != T[mm]) flag = false;
        nn += n;
        mm += m;
    }

    if (flag) cout << l << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
    char c[4], d[30] = {0};
    cin >> c;
    for(int i = 0; i < 4; i++){
        d[c[i]-'A'] += 1;
    }
    for(int i = 0; i <= (int)('Z' - 'A'); i++){
        if(d[i] != 0 && d[i] != 2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

typedef struct node_struct{
  vector<int> connections;
  int increment;
}node_t;

void fall_increment(int node_num, node_t &node, int inheritance);

node_t *nodes;
int *increments;

int main(void)
{
  int nodes_count;
  int increments_count;
  
  cin >> nodes_count >> increments_count;
  
  nodes = new node_t[nodes_count];
  for(int i = 0; i < nodes_count - 1; i++){
    int parent, child;
    cin >> parent >> child;
    nodes[parent - 1].connections.push_back(child - 1);
    
    nodes[i].increment = 0;
  }
  
  increments = new int[increments_count]();
  for(int i = 0; i < increments_count; i++){
    int point, increment;
    cin >> point >> increment;
    increments[point - 1] += increment;
  }

  fall_increment(0, nodes[0], 0);
  
  for(int i = 0; i < nodes_count; i++){
    cout << nodes[i].increment << " ";
  }
  
  cout << endl;
  
  return 0;
}

void fall_increment(int node_num, node_t &node, int inheritance)
{
  node.increment += increments[node_num] + inheritance;
  for(vector<int>::iterator itr = node.connections.begin(); itr != node.connections.end(); itr++){
    fall_increment(*itr, nodes[*itr], increments[node_num] + inheritance);
  }
  
}

Measured memory_bytes: 25088
#include<iostream>
using namespace std;
int main(void){
  
  int a, b, x;
  
  cin >> a >> b;
  
  x = (a + b)/2;
  
  if((a+b)%2 != 0){
    x++;
  }
  
  cout << x << endl;
  
  return 0;
}

Measured memory_bytes: 256
N=gets.to_i
s=gets.chomp.chars.map{|c|c=='o' ? 'S' : 'W'}

['SS','SW','WW','WS'].each do |t|
  2.upto(N-1) do |i|
    t << ((s[i-1]==t[-1])==(t[-2]=='S') ? 'S' : 'W')
  end
  if ((s[-1]==t[-1]) == (t[-2]==t[0])) &&
    (s[0]==t[0]) == (t[-1]==t[1])
    puts t
    exit 0
  end
end

puts -1


Measured memory_bytes: 16764
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define trace(x) cout << '>' << #x << ':' << x << "\n" 
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << "\n" 
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n" 
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n" 
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl '\n' 
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 1e5 + 10;

int n;
ll mx1,mi1,mx2,mi2;

int main()
{
    fastIO;
    cin >> n;
    mx1 = -1e18, mi1 = 1e18, mx2 = -1e18, mi2 = 1e18;

    for(int i = 0; i < n; ++i)
    {
        int x,y;
        cin >> x >> y;
        ll v1 = x + y, v2 = x - y;
        mx1 = max(v1,mx1);
        mi1 = min(v1,mi1);
        mx2 = max(v2,mx2);
        mi2 = min(v2,mi2);
    }
    cout << max(mx1 - mi1, mx2 - mi2) << endl;

    return 0;
}

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

int main(){
  long long int a,b,c;
  cin >> a;
  string s;
  cin >> s;
  s.erase(1,1);
  b = stoi(s);
  long long int ans = (a*b)/100;
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, p;
    cin >> a >> p;
    p += a * 3;
    p /= 2;
    cout << p << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll cnt = 0;
  ll cnt2 = 0;
  ll tot = 0;
  ll tot2 = 0;
  // 0番目を-にする場合
  rep(i, n) {
    if (i % 2) {
      if (tot + a[i] > 0)
        tot += a[i];
      else {
        cnt += abs(a[i] - (1 - tot));
        tot = 1;
      }
    } else {
      if (tot + a[i] < 0)
        tot += a[i];
      else {
        cnt += abs(a[i] - (-1 - tot));
        tot = -1;
      }
    }
  }
  // 0番目を+にする場合
  rep(i, n) {
    if (i % 2) {
      if (tot2 + a[i] < 0)
        tot2 += a[i];
      else {
        cnt2 += abs(a[i] - (-1 - tot2));
        tot2 = -1;
      }
    } else {
      if (tot2 + a[i] > 0)
        tot2 += a[i];
      else {
        cnt2 += abs(a[i] - (1 - tot2));
        tot2 = 1;
      }
    }
  }

  ll ans = min(cnt, cnt2);
  cout << ans << endl;
}


Measured memory_bytes: 4060
def compare_cards(a, b):
    return a[1] < b[1]

def bubble_sort(A):
    for i in range(len(A)):
        for j in range(len(A)-1, i, -1):
            if compare_cards(A[j], A[j-1]):
                A[j], A[j-1] = A[j-1], A[j]

def selection_sort(A):
    for i in range(len(A)):
        mini = i
        for j in range(i, len(A)):
            if compare_cards(A[j], A[mini]):
                mini = j
        A[i], A[mini] = A[mini], A[i]

def check_stable(originA, sortedA):
    for i in range(len(originA)-1):
        if not compare_cards(sortedA[i], sortedA[i+1]):
            if originA.index(sortedA[i]) > originA.index(sortedA[i+1]):
                return "Not stable"
    return "Stable"

N = int(input())
A = input().split()

bubbleA = list(A)
selectionA = list(A)

bubble_sort(bubbleA)
selection_sort(selectionA)

print(*bubbleA)
print(check_stable(A, bubbleA))

print(*selectionA)
print(check_stable(A, selectionA))

Measured memory_bytes: 7840
#include<iostream>
using namespace std;
int main(){
  int n,min=-1;
  cin >> n;
  int s[n];
  for(int i=0;i<n;i++){
    cin >> s[i];
    if(min<0||min>s[i]) min = s[i];
  }
  for(int i=1;i<=min;i++){
    for(int j=0;j<n;j++){
      if(s[j]%i!=0) break;
      if(j==n-1) cout << i << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    A=list(map(int,readline().split()))

    B=[0]*N
    for i in range(N):
        B[i]=A[i]-i
    B.sort()
    if N%2==1:
        b=B[N//2]
    else:
        b=(B[N//2-1]+B[N//2])//2
    
    res=0
    for i in range(N):
        res+=abs(B[i]-b)

    print(res)
if __name__=="__main__":
    main()

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

using namespace std;

typedef long long ll;
typedef long double ld;

map <int, int> u;
int seg[1000005];
int ima[1000005];
int niz[1000005];

void add(int node, int l, int r, int x){
    if(l == r){
        ima[l]++;
        seg[node] = x;
        return;
    }
    int mid = (l+r)/2;
    if(x <= mid) add(node*2, l, mid, x);
    else add(node*2+1, mid+1, r, x);
    seg[node] = max(seg[node*2], seg[node*2+1]);
}

void rem(int node, int l, int r, int x){
    if(l == r){
        ima[l]--;
        if(ima[l] == 0) seg[node] = 0;
        else seg[node] = x;
        return;
    }
    int mid = (l+r)/2;
    if(x <= mid) rem(node*2, l, mid, x);
    else rem(node*2+1, mid+1, r, x);
    seg[node] = max(seg[node*2], seg[node*2+1]);
}

int query(int node, int l, int r, int tl, int tr){
    if(tl > r || l > tr) return 0;
    if(tl <= l && r <= tr){
        return seg[node];
    }
    int mid = (l+r)/2;
    return max(query(node*2, l, mid, tl, tr), query(node*2+1, mid+1, r, tl, tr));
}

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    int n;
    cin >> n;
    vector <int> vec;
    for(int i=1; i<=n; i++){
        cin >> niz[i];
        vec.push_back(niz[i]);
    }
    sort(vec.begin(), vec.end());
    int cnt = 0;
    for(auto c : vec){
        if(!u[c]) u[c] = ++cnt;
    }
    for(int i=1; i<=n; i++){
        niz[i] = u[niz[i]];
    }
    int g = 0;
    for(int i=1; i<=n; i++){
        int x = query(1, 1, n, 1, niz[i]-1);
        if(x != 0) rem(1, 1, n, x);
        else g++;
        add(1, 1, n, niz[i]);
    }
    cout << g;
    return 0;
}


Measured memory_bytes: 13816
#define DEBUG 0
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-6-29 21:02:28
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using ll = long long;
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}
const int MAX_SIZE = 1000010;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a) { return (*this *= power(MOD - 2)); }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
mint inv[MAX_SIZE];
mint fact[MAX_SIZE];
mint factinv[MAX_SIZE];
void init()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = mint(i) * fact[i - 1];
    factinv[i] = inv[i] * factinv[i - 1];
  }
}
mint choose(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return fact[n] * factinv[k] * factinv[n - k];
  }
  return 0;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// const double epsilon = 1e-10;
// const ll infty = 1000000000000000LL;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

int N;
int p[100];

int main()
{
  // init();
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    cin >> p[i];
  }
  int ans = 0;
  for (auto i = 1; i < N - 1; i++)
  {
    if (p[i - 1] > p[i] && p[i + 1] > p[i])
    {
      continue;
    }
    if (p[i - 1] < p[i] && p[i + 1] < p[i])
    {
      continue;
    }
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 23680
#include<stdio.h>

int main()
{
	double a[1000]={0},dumy;
	int x=0;
	while(scanf("%lf",&a[x])!=EOF)
	{
		x++;
	}

	for(int i=0;i<x;i++)
	{
		for(int j=0;j<x;j++)
		{
			if(a[i]>a[j])
			{
				dumy=a[i];
				a[i]=a[j];
				a[j]=dumy;
			}
		}
	}

	printf("%.1f",a[0]-a[x-1]);
}

Measured memory_bytes: 1088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    int n = Integer.parseInt(br.readLine());
    String[] tmp = br.readLine().split(" ");
    int[] arr = Arrays.asList(tmp).stream().mapToInt(x -> Integer.parseInt(x)).toArray();

    printIntArray(arr);
    for (int i = 1; i < n; i++) {
      int v = arr[i];
      int j = i - 1;
      while (j >= 0 && arr[j] > v) {
        arr[j + 1] = arr[j];
        j--;
      }
      arr[j + 1] = v;
      printIntArray(arr);
    }
  }

  private static void printIntArray(int[] arr) {
    StringBuilder s = new StringBuilder();
    for (int i = 0; i < arr.length; i++) {
      s.append(arr[i]);
      if (i < arr.length - 1) {
        s.append(" ");
      }
    }
    System.out.println(s.toString());
  }
}

Measured memory_bytes: 31288
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 ]


bool isOverflow(long long a, long long b) 
{ 
    // Check if either of them is zero 
    if (a == 0 || b == 0)  
        return false; 
      
    long long result = a * b; 
    if (a == result / b) 
        return false; 
    else
        return true; 
} 


int32_t main() {
  fastio;
  ld a,b;
  cin>>a>>b;
  ll ans = a*b;
  cout<<ans<<endl;
}

Measured memory_bytes: 3748
#include "bits/stdc++.h"
using namespace std;


typedef long long ll;
    typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;
int m;
int ans;
string str;

int main(){
    int v[25],c[25];
    int ans=0;
    cin>>n;
    forn(i){
        cin>>v[i];
    }
    forn(i)cin>>c[i];
    forn(i)(v[i]-c[i]>0)?ans+=v[i]-c[i]:0;
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll x=0;
    ll flag_max=0;
    for(ll i=0;i<n;++i){
        if(s[i]=='I'){
            x+=1;
            flag_max=max(flag_max,x);
        }else if(s[i]=='D'){
            x-=1;
        }
    }
    cout<<flag_max<<endl;
}

Measured memory_bytes: 256
N = int(input())
p = list(map(float, input().split()))
dp = [0] * (N+1) # the probability of getting j heads
dp[0] = 1
for i in range(N):
    ndp = [0] * (N+1)
    ndp[0] = dp[0] * (1 - p[i])
    for j in range(1, N+1):
        ndp[j] = dp[j-1] * p[i] + dp[j] * (1 - p[i])
    dp = ndp
print(sum(dp[N//2+1:]))

Measured memory_bytes: 48604
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define push_back pb
#define int long long int
int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--)
	{
		int n, ans = 0;
		cin >> n;
		int a[n], b[n];
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}
		b[0] = 0;
		int tmpu = 0;
		for (int i = 1; i < n; i++)
		{
			int temp = a[tmpu] - a[i];
			if (temp > 0)
				b[i] = temp;
			else
			{
				b[i] = 0;
				tmpu = i;
			}
		}
		for (int i = 0; i < n; i++)
			ans += b[i];

		cout << ans;
	}
	return 0;
}


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

int main(void)
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		string a, b, str;
		cin >> str;
		a += 'A'; a += str;
		cin >> str;
		b += 'A'; b += str;
		string ret;
		int num1 = 0, num2 = 0;
		for (int j = 0; j < a.length(); j++){
			if (a[j] == 'm'){
				if ('2' <= a[j-1] && a[j-1] <= '9'){
					num1 += (a[j-1]-'0') * 1000;
				}
				else num1 += 1000;
			}
			if (a[j] == 'c'){
				if ('2' <= a[j-1] && a[j-1] <= '9'){
					num1 += (a[j-1]-'0') * 100;
				}
				else num1 += 100;
			}
			if (a[j] == 'x'){
				if ('2' <= a[j-1] && a[j-1] <= '9'){
					num1 += (a[j-1]-'0') * 10;
				}
				else num1 += 10;
			}
			if (a[j] == 'i'){
				if ('2' <= a[j-1] && a[j-1] <= '9'){
					num1 += (a[j-1]-'0') * 1;
				}
				else num1 += 1;
			}
		}
		for (int j = 0; j < b.length(); j++){
			if (b[j] == 'm'){
				if ('2' <= b[j-1] && b[j-1] <= '9'){
					num2 += (b[j-1]-'0') * 1000;
				}
				else num2 += 1000;
			}
			if (b[j] == 'c'){
				if ('2' <= b[j-1] && b[j-1] <= '9'){
					num2 += (b[j-1]-'0') * 100;
				}
				else num2 += 100;
			}
			if (b[j] == 'x'){
				if ('2' <= b[j-1] && b[j-1] <= '9'){
					num2 += (b[j-1]-'0') * 10;
				}
				else num2 += 10;
			}
			if (b[j] == 'i'){
				if ('2' <= b[j-1] && b[j-1] <= '9'){
					num2 += (b[j-1]-'0') * 1;
				}
				else num2 += 1;
			}
		}
		//cout << num1 << " " << num2 << endl;
		num1 += num2;
		//cout << num1 << endl;
		if (2 <= (num1 / 1000) && (num1 / 1000) <= 9) {
			cout << num1 / 1000 << 'm';
			num1 %= 1000;
		}
		if (num1 / 1000 == 1) {
			cout << 'm';
			num1 -= 1000;
		}
		if (2 <= (num1 / 100) && (num1 / 100) <= 9) {
			cout << num1 / 100 << 'c';
			num1 %= 100;
		}
		if (num1 / 100 == 1) {
			cout << 'c';
			num1 -= 100;
		}
		if (2 <= (num1 / 10) && (num1 / 10) <= 9) {
			cout << num1 / 10 << 'x';
			num1 %= 10;
		}
		if (num1 / 10 == 1) {
			cout << 'x';
			num1 -= 10;
		}
		if (2 <= num1 && num1 <= 9) {
			cout << num1 << 'i';
		}
		if (num1 == 1) cout << 'i';
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 0
k = int(input())
a, b = map(int, input().split())
flag = 0

if k == a:
    flag = 1
elif k < a:
    if a % k == 0 :
        flag = 1
    elif (int(a / k)+1) * k <= b:
        flag = 1
elif a < k:
    if k <= b:
        flag = 1

  
if flag:
  print("OK")
else:
  print("NG")

Measured memory_bytes: 9052
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/

int main() {
    ll n;
    cin>>n;
    vi a(n);
    REP(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    ll pivot=a[n-1]/2;
    ll idx=lower_bound(a.begin(),a.end(),pivot)-a.begin();
    if (idx==0) {}
    else if(a[n-1]%2==0){
        if(llabs(a[idx]-pivot)>llabs(a[idx-1]-pivot))idx-=1;
    }else{
        if(llabs(a[idx]-pivot-1)>llabs(a[idx-1]-pivot))idx-=1;
    }
    if(idx==n-1)idx--;
    cout<<a[n-1]<<" "<<a[idx]<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    map<ll,ll> mp;
    ll ans = 0;

    rep(i,n){
        cin >> a[i];
        mp[a[i]]++;
        ans += a[i];
    }

    ll q; cin >> q;

    rep(i,q){
        ll b, c; cin >> b >> c;
        ans -= mp[b] * b;
        ans += mp[b] * c;
        mp[c] += mp[b];
        mp[b] = 0;
        cout << ans << endl;
    }

    for(auto e: mp){
        ans += e.second * e.first;
    }

    //cout << ans << endl;



}

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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  int ans=0;
  rep(i,N){
    int a;
    cin >> a;

    while(a%2==0){
      a/=2;
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3604
import numpy as np 

def main():
    n,d=map(int,input().split())
    
    x=[]
    for i in range(n):
        tmp=list(map(int,input().split()))
        x.append(np.array(tmp))
    
   # print(x)

    cnt=0
    
    for k in range(n-1):
        for l in range(k+1,n):
            dist=np.sqrt(np.sum((x[k]-x[l])*(x[k]-x[l])))

            if float.is_integer(dist):
                cnt+=1

    print(cnt)

if __name__=="__main__":
    main()

Measured memory_bytes: 12484
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

mia, pla = [], []
for ai in a:
    if ai < 0:
        mia.append(ai)
    elif ai >= 0:
        pla.append(ai)
mia.sort(reverse=True)
pla.sort()

cnt = 1
if len(pla) == 0 and k % 2 == 1:
    for i in mia[:k]:
        cnt = cnt * i % mod
else:
    while k > 0:
        if k == 1 or len(mia) <= 1:
            if len(pla) == 0:
                cnt = cnt * mia.pop()
            elif len(pla) > 0:
                cnt = cnt * pla.pop()
            k -= 1
        elif len(pla) <= 1:
            cnt = cnt * mia.pop() * mia.pop()
            k -= 2
        elif len(pla) >= 2 and len(mia) >= 2:
            if pla[-1] * pla[-2] > mia[-1] * mia[-2]:
                cnt = cnt * pla.pop()
                k -= 1
            elif pla[-1] * pla[-2] <= mia[-1] * mia[-2]:
                cnt = cnt * mia.pop() * mia.pop()
                k -= 2
        cnt %= mod
print(cnt)


Measured memory_bytes: 32028
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int R = sc.nextInt();
			
			System.out.printf("%.10f\n", 2 * Math.PI * R);
			
		}
	}

	public static class Scanner implements Closeable {
		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() {
			return tok != null && 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 int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

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


Measured memory_bytes: 34536
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


ll com[51][51];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    com[0][0]=1;
    for(int i=1;i<51;i++){
        for(int j=0;j<=i;++j){
            com[i][j] += com[i-1][j];
            if(j>0) com[i][j] += com[i-1][j-1];
        }
    }
    int N,A,B;
    cin>>N>>A>>B;
    vector<ll> v(N);
    for(int i=0;i<N;i++) cin>>v[i];
    VRSORT(v);

    ll sum=0;
    for(int i=0;i<A;i++) sum+=v[i];
    double ave = (double)(sum)/A;

    ll res = 0;
    int num = 0;
    for(int i=0;i<N;i++) if(v[i]==v[A-1]) ++num;
    if(v[0]==v[A-1]){
        for(int j=A;j<=B;++j){
            res += com[num][j];
        }
    }
    else{
        int a=0;
        for(int i=0; i<A;++i) if(v[i]==v[A-1]) ++a;
        res = com[num][a];
    }
    cout << fixed << setprecision(10) << ave << endl;
    cout<<res<<endl;
}

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

int main() {
    int n, mi = 10000000, ma = -10000000;
    long long sum = 0;
    cin >> n;
    int i, b;
    for(i = 0; i < n; i++) {
        cin >> b;
        mi = min(mi, b);
        ma = max(ma, b);
        sum += b;
    }
    cout << mi << " " << ma << " " << sum << endl;

    return 0;
}


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

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

  int flag = 0, ans = 0;
  int i = 1;
  while(i < n){
    if(a[i] == a[i-1])i++;
    else if(a[i-1] < a[i]){
      if(flag == 0) {flag = 1; i++;}
      else if (flag == 1) i++;
      else{ans++; i++; flag =0;}
    }
    else if (a[i-1] > a[i]){
      if(flag == 0){flag = -1; i++;}
      else if (flag == -1){ i++;}
      else {ans++; i++; flag = 0;}
    }
  }
  cout << ans+1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>

typedef long long ll;

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    bool isAC[n+1];
    int wa[n+1];
    for(int i=1; i<n+1; i++)
    {
        isAC[i] = false;
        wa[i] = 0;
    }
    for(int i=0; i<m; i++)
    {
        int p;
        string s;
        cin >> p >> s;
        if(isAC[p]) continue;
        else
        {
            if(s == "WA") wa[p]++;
            else isAC[p] = true;
        }
    }
    int AC=0,WA=0;
    for(int i=1; i<n+1; i++)
    {
        if(isAC[i])
        {
            AC++;
            WA += wa[i];
        }
    }
    cout << AC << ' ' << WA;
}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var nm = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var req = new int[nm[1]][];
        for (var i = 0; i < nm[1]; i++)
            req[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        req = req.OrderBy(ab => ab[1]).ToArray();
        var then = -1;
        var res = 0;
        for(var i = 0; i < nm[1]; i++)
        {
            if (then <= req[i][0])
            {
                then = req[i][1];
                res++;
            }
        }
        WriteLine(res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}

Measured memory_bytes: 28100
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

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

func reverse(a sort.Interface, start int, size int) {
	for end := start + size - 1; start < end; start++ {
		a.Swap(start, end)
		end--
	}
}

func layer(n int) int {
	if n == 1 {
		return 1
	}
	return 1 + 2*layer(n/2)
}

func main() {
	h := nextInt()

	fmt.Println(layer(h))
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <unordered_map>

typedef long long ll;

int main (void) {
  int N;
  std::cin >> N;

  std::vector<ll> A;
  A.resize(N);

  int count_minus = 0;
  ll sum = 0;
  for(int i=0; i<N; i++){
    std::cin >> A[i];
    sum += std::abs(A[i]);
    if ( A[i] < 0  ) count_minus++;
  }

  ll min_abs = 999999999999;
  for(int i=0; i<N; i++){
    min_abs = std::min(min_abs, std::abs(A[i]));
  }

  if (count_minus % 2 == 0) std::cout << sum << std::endl;
  else std::cout << sum - (2*min_abs) << std::endl;

  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

ull f( ull a )
{
	ull ret = 0;
	ull mod4 = a % 4;
	if( mod4 == 0 ) ret += 0;
	if( mod4 == 1 ) ret += 1;
	if( mod4 == 2 ) ret += 3;
	if( mod4 == 3 ) ret += 0;
	for( ull i = 2; i < 42; ++i )
	{
		ull p = 1ull << ( i + 1 );
		ull mod = a % p;
		if( mod < p / 2 ) { continue; }
		if( mod % 2 == 0 )
		{
			ret += 1ull << i;
		}
	}
	return ret;
}

int main()
{
	ull a, b;
	cin >> a >> b;
	ull c = f( b ) ^ f( a - 1 );
	cout << c << endl;
	return 0;
}

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




int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int a, b;
	cin >> a >> b;
	int mini = max(a,b), maxi = min(a,b);
	string s = "";
	string t = to_string(maxi);
	for (int i = 1; i <= mini; ++i)
		s += t;
	cout << s << "\n";
}

Measured memory_bytes: 256
/*input
-1000000000 0 -1000000000 0
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long

signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans = -1e18;
	for(int i : {a*c, a*d, b*c, b*d}){
		ans = max(ans, i);
	}
	cout<<ans;
	return 0;	
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

vector<int> v;
priority_queue<int, vector<int>, greater<int> > w;

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

    int N, K;
    std::cin >> N >> K;

    for(int i=0;i<N;++i){
        int x;
        std::cin >> x;
        
        v.emplace_back(x);
    }

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

    for(int i=0,j=0;i<v.size();i=j){
        while(j < v.size() && v[j] == v[i]){
            ++j;
        }

        w.emplace(j - i);
    }

    int res = 0;
    while(w.size() > K){
        res += w.top();
        w.pop();
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 2548
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

class Comb {
 public:
  Comb() {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kMax; i++){
        fact[i] = fact[i-1] * i % kMod;
        inv[i] = kMod - inv[kMod%i] * (kMod / i) % kMod;
        finv[i] = finv[i-1] * inv[i] % kMod;
    }
  }

  LL nCr(int n, int r) const {
    LL numerator = fact[n];
    LL denominator = finv[r] * finv[n-r] % kMod;
    return (numerator * denominator) % kMod;
  }

 private :
  static constexpr int kMax = 1e7;
  LL fact[kMax];
  LL inv[kMax];
  LL finv[kMax];
};

int main() {
  int X, Y; std::cin >> X >> Y;
  if((X + Y)%3 != 0) {
    std::cout << 0 << std::endl;
    return 0;
  }

  int a = (2*Y-X)/3;
  int b = (2*X-Y)/3;
  if (a < 0 || b < 0) {
    std::cout << 0 << std::endl;
    return 0;
  }

  static Comb C;
  std::cout << C.nCr(a + b, a) << std::endl;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll n,m;
vector<tuple<ll,ll>> ab;
ll ans = 0;

int main(){
    cin >> n >> m;
    ab = vector<tuple<ll,ll>>(m);
    for(ll i = 0;i < m;i++){
        ll a,b;
        cin >> a >> b;
        ab[i] = make_tuple(a,b);
    }
    sort(ab.begin(),ab.end());
    ll r = INF;
    for(ll i = 0;i < m-1;i++){
        ll a,b,next_a,next_b;
        tie(a,b) = ab[i];
        tie(next_a,next_b) = ab[i+1];
        r = min(r,b);
        if(next_a >= r){
            ans++;
            r = INF;
        }


    }
    ans++;
    cout << ans << endl;
}


Measured memory_bytes: 4796
// C - Sum of product of pairs
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	vector<int> A(N);
	int MOD = (1e9) + 7;
	int64_t sum_a = 0;
	for(int i=0; i<N; ++i){
		cin>>A[i];
		sum_a += A[i];
	}
	int64_t ans = 0;
	for(int a:A){
		sum_a -= a;
		sum_a %= MOD;
		ans += sum_a * a % MOD;
		ans %= MOD;
	}
	cout<< (ans + MOD) % MOD <<endl;
}


Measured memory_bytes: 4052
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    int h, a;
    cin >> h >> a;
    cout << (h+a-1)/a << endl;
}

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

using namespace std;

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  int count = 0;
  for (int i = 0; i < N - 2; i++) {
    if (S.substr(i, 3) == "ABC") {
      count++;
    }
  }
  cout << count << endl;
}

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

int main() {
    
    /* Input */
    int K;
    cin >> K;

    int ans = -1;

    /* Main Logic */
    int an = 0;
    for (int i = 1; i <= K; i++) {
        if (i == 1) {
            an = 7 % K;
        } else {
            an = (an * 10 + 7) % K;
        }

        if (an % K == 0) {
            ans = i;
            break;
        }
    }

    /* Output */
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int l = n - m,sis = 1;
  for(int i = 0;i < m;i++){
    sis *= 2;
  }
  int kekka = (100*l + 1900*m)*sis;
  cout << kekka << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    long long r,d,x;
    scanf("%lld%lld%lld",&r,&d,&x);
    for(int i=1;i<=10;i++)
    {
        x=x*r-d;
        printf("%lld\n",x);
    }
    return 0;
}


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

int main(void){
	int a,b=0,c=0,i;
	char d[100000];
	scanf("%s",d);
	a = strlen(d);
	
	for(i=0;i<a;i++){
		if(i%2==0) {
			if(d[i] == '1') b = b+1;
		}
		if(i%2==1){
			if(d[i] == '0') b = b+1;
		}
		
		if(i%2==0) {
			if(d[i] == '0') c = c+1;
		}
		if(i%2==1){
			if(d[i] == '1') c = c+1;
		}
	}
	if(b>c) printf("%d\n",c);
	else  printf("%d\n",b);
	
	return 0;
}


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

using namespace std;

int main()
{
  double mn = 1000000, mx = -1;
  double tmp;
  while (scanf("%lf ", &tmp) == 1) {
    mn = min(mn, tmp);
    mx = max(mx, tmp);
  }
  printf("%lf\n", mx - mn);
}

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

typedef long long ll;
typedef pair<ll,ll> P;

#define fr first
#define sc second
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)

const ll MOD=998244353;

ll x[100010];
void init(){
	x[0]=1e+18;
	//x[0]=2;
	x[0]%=MOD;
	for(int i=1;i<100010;i++){
		x[i]=x[i-1]*x[0];
		x[i]%=MOD;
	}
}

ll modpow(ll x,ll k){
	if(k==0)return 1;
	ll ret=modpow(x,k/2);
	ret*=ret;
	ret%=MOD;
	if(k%2==1){
		ret*=x;
		ret%=MOD;
	}
	return ret;
}

struct Graph{
	int n,m;
	vector<int> G[100010];
	int k;
	ll ret[100010];
	bool used[100010];
	bool used2[100010];
	int run(){
		memset(used,0,sizeof used);
		int zan=n;
		k=0;
		while(zan>0){
			ret[k]=0;
			memset(used2,0,sizeof used2);
			for(int i=n;i>=1;i--){
				if(used[i])continue;
				used2[i]=true;
				for(int v: G[i]){
					if(used2[v]){
						used2[i]=false;
						break;
					}
				}
				if(used2[i]){
					ret[k]+=x[i-1];
					if(ret[k]>=MOD)ret[k]-=MOD;
					zan--;
					used[i]=true;
					//cerr<<i<<" "<<k<<" "<<x[i]<<" "<<ret[k]<<endl;
				}
			}
			k++;
		}
		/*cerr<<k<<endl;
		for(int i=0;i<k;i++){
			cerr<<ret[i]<<" ";
		}cerr<<endl;*/
		return k;
	}
}G[3];

int main(){
	init();
	scanf("%d",&G[0].n);
	G[1].n=G[0].n;
	G[2].n=G[0].n;
	int k=MOD;
	for(int t=0;t<3;t++){
		scanf("%d",&G[t].m);
		for(int i=0;i<G[t].m;i++){
			int a,b;
			scanf("%d%d",&a,&b);
			if(a>b)G[t].G[b].push_back(a);
			else G[t].G[a].push_back(b);
		}
		chmin(k,G[t].run());
	}
	
	static ll a[1<<17];
	for(int i=0;i<G[1].k;i++){
		for(int j=0;j<G[2].k;j++){
			a[i^j]+=G[1].ret[i]*G[2].ret[j];
			a[i^j]%=MOD;
		}
	}
	
	ll ret=0;
	for(int i=0;i<G[0].k;i++){
		a[i]*=G[0].ret[i];
		ret+=a[i]; ret%=MOD;
	}
	cout<<ret%MOD<<endl;
}

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

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

  int tmp;
  bool fin = false;
  for(int i = x;i >= 1 && !fin;i--){
    for(int j = 2;j <= i;j++){
      tmp = j;
      while(1){
        tmp = tmp * j;
        if(tmp >= i){
          break;
        }
      }
      if(tmp == i){
        cout << i << endl;
        fin = true;
        break;
      }
    }
  }

  if(!fin)
    cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
      	if(s.equals("SUN"))
        {
			System.out.println(7);        
        }
      	else if(s.equals("MON"))
        {
			System.out.println(6);        
        }
        else if(s.equals("TUE"))
        {
			System.out.println(5);        
        }
        else if(s.equals("WED"))
        {
			System.out.println(4);        
        }
        else if(s.equals("THU"))
        {
			System.out.println(3);        
        }
        else if(s.equals("FRI"))
        {
			System.out.println(2);        
        }
      	else if(s.equals("SAT"))
        {
			System.out.println(1);        
        }
	}
}

Measured memory_bytes: 21844
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	private static final int[] NUM_DAYS= {
		31,
		29,
		31,
		30,
		31,
		30,
		31,
		31,
		30,
		31,
		30,
		31
	};
	
	public static void main(String[] args) {
		ArrayList<String> result = new ArrayList<String>();
		Scanner sc = new Scanner(System.in);
		while(true){
			//ツ個篠禿コツづーツ偲ウツつッツ偲ヲツづゥ
			int month = sc.nextInt();
			int day = sc.nextInt();
			if(month == 0){
				break;
			}
			
			//ツ禿シツ療債個篠禿コツづ慊づづ個禿コツ青板づーツ仰づ淞づゥ
			int days = 0;
			for(int i = 1; i < month; i++){
				days += NUM_DAYS[i - 1];
			}
			days += day;
			
			//ツ曜ツ禿コツづーツ算ツ出ツつオツ個仰嘉環δ環スツトツづ可津嘉つキツづゥ
			int date = days % 7;
			switch(date){
			case 0:
				result.add("Wednesday");
				break;
			case 1:
				result.add("Thursday");
				break;
			case 2:
				result.add("Friday");
				break;
			case 3:
				result.add("Saturday");
				break;
			case 4:
				result.add("Sunday");
				break;
			case 5:
				result.add("Monday");
				break;
			case 6:
				result.add("Tuesday");
				break;
			}
		}
		
		for(int i = 0; i < result.size(); i++){
			System.out.println(result.get(i));
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define f(i,p,q) for(int i=p;i<q;i++)
using namespace std;
int main()
{
   // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
     int n,x;cin>>n;
     int ar[n];
     int max_num=0;
     int sum=0;
     for(int i=0;i<n;i++)
        { 
          cin>>x;
		  sum+=x;
		  if(max_num<x)
		    max_num=x;	
		}
     if(sum-max_num>max_num)
	   cout<<"Yes";
	   else
	    cout<<"No"; 
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Diagnostics.Tracing;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //int n=ReadInt();
            //string[] str = Console.ReadLine().Split(' ');

            string s = Console.ReadLine();

            int temp = 0;

            for(int i = 0; i < s.Length; i++)
            {
                int p = int.Parse(s[i].ToString());
                temp += p;
                temp %= 9;
            }

            if (temp == 0) Cout("Yes");
            else Cout("No");


            //ここまで
        }

        static void Cout(string s)
        {
            Console.WriteLine(s);
            return;
        }

        static void Cout(int n)
        {
            Console.WriteLine(n);
            return;
        }

        static void Cout(long n)
        {
            Console.WriteLine(n);
            return;
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] ReadArray(int n)
        {
            string[] str = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for (int i=0; i < n; i++){ a[i] = int.Parse(str[i]); }
            return a;
        }
        static long[] ReadArray(long n)
        {
            string[] str = Console.ReadLine().Split(' ');
           long[] a = new long[n];
            for (long i = 0; i < n; i++) { a[i] = long.Parse(str[i]); }
            return a;
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int Min(int a, int b)
        {
            if (a < b) return a;
            return b;
        }

        static int Max(int a, int b)
        {
            if (a > b) return a;
            return b;
        }


    }

}


Measured memory_bytes: 32856
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
    cin>>a>>b;
    if(b==1)
    {
        cout<<'0'<<endl;
        return 0;
    }
    int ans = 1;
    b -= a;a--;
    /*while(b)
    {
        b -= a;
        ans ++;
    }*/
    if(b>0)
        ans += (b+a-1)/a;
    cout<<ans<<endl;

}


Measured memory_bytes: 256