akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    String s = sc.next();
    ArrayList<Integer> list = new ArrayList<Integer>();
    list.add(0);
    for(int i = 1; i < s.length(); i++) {
      if(s.charAt(i) != s.charAt(i - 1)) list.add(i);
    }
    int p = list.size();
    for(int i = 0; i < 2 * k + 1; i++) {
      list.add(n);
    }
    Collections.sort(list);
    int ans = 0;
    for(int i = 0; i < p; i++) {
      if(s.charAt(list.get(i)) == '0') {
        ans = Math.max(ans, list.get(i + 2 * k) - list.get(i));
      } else {
        ans = Math.max(ans, list.get(i + 2 * k + 1) - list.get(i));
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 30912
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}
void pr (int f)
{
    if(f==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
int main()
{
    fast;
    int x,k=0,n;
    vector<int>v;
    vector<int>vv;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>x;
        v.push_back(x);
    }
    for(int j=1; j<=100; j++)
    {
        k=0;
        for(int i=0; i<v.size(); i++)
        {
            k+=((v[i]-j)*(v[i]-j));
        }
        vv.push_back(k);
    }
    sort(vv.begin(),vv.end());
    cout<<vv[0]<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

int main() {
    ld a, b;

    cin >> a >> b;

    cout << fixed << setprecision(0);
    cout << floor(a * b) << endl;
    return 0;
}

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


long long int  func(long long int n, long long int r) 
{ 

 
  long long int p = 1, k = 1; 

  
  if (n - r < r) 
    r = n - r; 

  if (r != 0) { 
    while (r) { 
      p = 1LL*p*n; 
      k = 1LL*k*r; 

      // gcd of p, k 
      long long int m = __gcd(p, k); 

      // dividing by gcd, to simplify product 
      // division by their gcd saves from the overflow 
      p /= m; 
      k /= m; 

      n--; 
      r--; 
    } 
  } 

  else
    p = 1; 

   return p;
} 


int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
  

   int a,b;
   cin>>a>>b;
   cout<<a*b<<endl;
return 0;
}


Measured memory_bytes: 3660
N,K = map(int,input().split())
x = list(map(int,input().split()))

ans = float('inf')
for i in range(N-K+1):
  l = x[i]
  r = x[i+K-1]
  temp = min(abs(l)+abs(r-l),abs(r)+abs(l-r))
  ans = min(temp,ans)

print(ans)

Measured memory_bytes: 14252
#include <stdio.h>
int main(){
  int H,W,i,n;
  while(1){
    scanf("%d %d",&H,&W);
    if(H == 0 && W == 0) break;
    else for(i=0;i<H;i++){
	for(n=0;n<W;n++){
	  printf("#");
	}
	printf("\n");
      }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    long long x,y;
    cin >> x >> y;
    long long cur = x;
    int cnt = 1;
    while(2*x <= y){
        x = 2*x;
        cnt ++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;

int main(){
    cout << fixed << setprecision(6);
    int n; cin >> n;
    string s,t; cin >> s >> t;
    string out ="";
    for (int i = 0; i < n; i++)
    {
        out += s[i];
        out += t[i];
    }
    cout << out << endl;
    
    return 0;
}

Measured memory_bytes: 3024
x,k,d = map(int,input().split())

x = abs(x)

if d*k > x:
    m = x//d
    pos = x - m*d
    neg = d*(m+1)-x
    if abs(k - m) % 2 == 0:
        print(pos)
    else:
        print(neg)
else:
    print(x - d*k)

Measured memory_bytes: 61868
def main():
	y, m, d = map(int, input().split("/"))
	if y > 2019:
		print("TBD")
		return
	if m > 4:
		print("TBD")
		return
	if d > 30:
		print("TBD")
		return
	print("Heisei")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
	
int main(){
	string a, b, c;
	cin >> a >> b >> c;
	char A = a[0] - 0x20, B = b[0] - 0x20, C = c[0] - 0x20;
	cout << A << B << C << endl;
}

Measured memory_bytes: 256
X,Y=map(int,input().split())
ret='No'
if Y%2==0 or Y<=4*X or Y>=2*X:
    for i in range(0,X+1):
        #print('turu:' + str(2*i) + ' kame:' + str(4*(X-i)))
        if (2*i)+(4*(X-i))==Y:
            ret='Yes'
print(ret)

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

int N; //頂点の数
vector<vector<int>> G; //グラフ
vector<int> h; //入次数
vector<int> l_depth; //最大経路長
vector<int> ans; //トポロジカルソート結果を格納

void input(){
  int n;
  cin>>n;
  vector<vector<int>> IDs(n, vector<int>(n, -1));
  N = n*(n-1)/2;
  G.resize(N);
  h.resize(N, 0);
  l_depth.resize(N, -1);

  int id = 0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      IDs[i][j] = id;
      IDs[j][i] = id;
      id++;
    }
  }

  int t, bufid, vsid;
  for(int i=0; i<n; i++){
    bufid = -1;
    for(int j=0; j<n-1; j++){
      cin>>t;t--;
      vsid = IDs[i][t];

      if(bufid != -1){
        G[bufid].push_back(vsid);
        h[vsid]++;
      }

      bufid = vsid;
    }
  }
}

void topoBFS(){   
  queue<int> unchecked;
  for(int i=0; i<N; i++){
    if(h[i]==0){
      unchecked.push(i); //入次数が0の頂点をキューに入れる
      l_depth[i] = 0; //そのような頂点は深さが0
    }
  }
  while(!unchecked.empty()){
    int current = unchecked.front();
    unchecked.pop();
    ans.push_back(current); //キューから取り出したらすぐソート後のリストに加える

    for(int next: G[current]){ //「行ける」頂点について
      h[next]--; //入次数を減らす
      l_depth[next] = max(l_depth[next], l_depth[current]+1); //最長経路
      if(h[next]==0){ //入次数0になったらキューに追加
        unchecked.push(next);
      }
    }
  }
}

int main(){
  input();
  
  topoBFS();

  bool isDAG = ans.size()==N;
  if(isDAG){
    int l_max = l_depth[ans.back()];
    cout<<l_max+1<<endl;
  }else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 37376
sub f{my$a=pop;
	$$a{$_}>$x[$_]&&($d+=++$x[$_],f($_),$d-=$x[$_]--)for 2..$N;
	$%+=$d==$N
}
$N=<>;${$`}{$'+0}=${$'+0}{$`}=/ / for<>;
f$d=1;
print$%,$/


Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class AMultiplication1 {
public:
    void solve(std::istream &in, std::ostream &out) {
        int a, b;
        in >> a >> b;
        int res = a * b;
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    AMultiplication1 solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
   ll a, b;
   cin >> a >> b;
   string x, y;
   rep(i, a){
   	x.pb(b+'0');
   }
   rep(i, b){
   	y.pb(a+'0');
   }
   ll m = stoll(x);
   ll n = stoll(y);
   cout << max(m, n) << endl;
}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,a=0,b=0;
  cin>>n;
  vector<int>d(n);
  rep(i,n){
    cin>>d.at(i);  
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  rep(i,n){
    if (i%2==0) {
      a+=d.at(i);
    }  
    else{
      b+=d.at(i);
    }
  }
  cout<<a-b<<endl;
}

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

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

	int a,b,c;
	cin >> a>>b>>c;
	int min1 = a+b;
	int min2 = a+b;
	int cnt;
	if(a+b<=a+c &&a+b<=b+c)
		cout<< a+b<<endl;
	else if(a+c<=a+b&&a+c<=b+c)
		cout <<a+c<<endl;
	else if(b+c<a+b&&b+c<a+c)
		cout <<b+c<<endl;

	return 0;
}

Measured memory_bytes: 256
'use strict'

const main = s => {
  const nums = s.split('\n')[1].split(' ').map(n => Number(n));
  const odd_len = nums.filter(n => n % 2 === 1).length;

  const answer = (odd_len % 2 === 0) ? 'YES' : 'NO';
  console.log(answer);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

// main.cpp

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

  std::int_fast64_t answer = 0;
  for (std::int_fast64_t i = 0; i <= a; ++i) {
    for (std::int_fast64_t j = 0; j <= b; ++j) {
      for (std::int_fast64_t k = 0; k <= c; ++k) {
        if (500 * i + 100 * j + 50 * k == x) ++answer;
      }
    }
  }

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        sc.close();
        insertionSort(A, N);

    }

    private static void insertionSort(int[] A, int N) {
        print(A, N);
        for(int i = 1; i < N; i++){
            int v = A[i];
            int j = i - 1;
            while(j >= 0 && A[j] > v){
                A[j+1] = A[j];
                j--;
            }
            A[j+1] = v;
            print(A, N);
        }

    }

    private static void print(int[] a, int n) {
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(a[i]);
            if(i != n -1) {
                sb.append(" ");
            }
        }
        System.out.println(sb.toString());

    }

}



Measured memory_bytes: 28968
s = input()
index = 0
total = 0
count_less = 0
count_more = 0
while index < len(s):
    count = 0
    while index < len(s) and s[index] == '<':
        count += 1
        index += 1
    count_more = count
    count = 0
    while  index < len(s) and s[index] == '>':
        count += 1
        index += 1
    count_less = count
    if count_more == count_less:
        total += count_less * (count_less + 1) - count_less
    elif count_less > count_more:
        total += count_less * (count_less + 1) // 2
        total += count_more * (count_more - 1) // 2
    else:
        total += count_more * (count_more + 1) // 2
        total += count_less * (count_less - 1) // 2
print(total)

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

int main(){
    string stralph = "abcdefghijklmnopqrstuvwxyz";

    string S, T;
    cin >> S >> T;

    int n_alph_S[26];
    int n_alph_T[26];
    for (int i=0; i<26; i++) {
        n_alph_S[i] = 0;
        n_alph_T[i] = 0;
    }

    int N = S.size();
    for (int i=0; i<N; i++) {
        n_alph_S[(int)S[i]-97]++;
        n_alph_T[(int)T[i]-97]++;
    }

    sort(n_alph_S, n_alph_S+26);
    sort(n_alph_T, n_alph_T+26);

    for (int i=0; i<26; i++){
        if (n_alph_S[i] != n_alph_T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

#define ll long long

const int MAXN = 2e5+3;
ll maxDistance;

ll d[MAXN];

int k,n;



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

    for (int i = 1; i <= n; i ++)
    {
        cin >> d[i];
    }

    maxDistance = k - d[n] + d[1];

    for (int i = 1; i <= n ; i ++)
    {
        maxDistance = max(maxDistance,d[i+1]-d[i]);
    }

    cout << k - maxDistance;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;

long wid[51], pathe[51];

long rec(int l, long x){
    if(x == 0) return 0;
    if(l == 0) return 1;
    long ans = 0;
    ans += pathe[l-1] * (x / (wid[l-1]+1));
    if(x > wid[l-1] + 1) ans++;
    long rest;
    if(x / (wid[l-1]+1) == 0) rest = x-1;
    if(x / (wid[l-1]+1) == 1) rest = max(0l, x-2-wid[l-1]);
    if(x / (wid[l-1]+1) == 2) rest = 0;
    return ans + rec(l-1, rest); 
}

int main(){
    long N, X;
    cin >> N >> X;
    wid[0] = 1; pathe[0] = 1;
    for(int i=1; i<=N; i++){
        wid[i] = wid[i-1] * 2 + 3;
        pathe[i] = pathe[i-1] * 2 + 1;
    }
    cout << rec(N, X) << endl;
    return 0;
}

Measured memory_bytes: 256
S=input()
s=""
s1=""
s2=""
for i in range(len(S)-1):
    s=S[:len(S)-i-1]
    if (len(s)%2==0):
        s1=s[:int(len(s)/2)]
        s2=s[int((len(s)+1)/2):]
        if s1==s2:
            print(len(s))
            break

Measured memory_bytes: 38256
MOD = 10**9+7

N = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7
RGB = [0]*3
ans = 1
for i in A:
    count = 0
    for j in RGB:
        if i == j:
            count += 1
    if count == 0:
        print(0)
        exit()
    RGB[RGB.index(i)] += 1
    ans = (ans * count)% MOD

print(ans)


Measured memory_bytes: 14020
#include <stdio.h>

int main()

{

    long long int r, d, x, i;

    scanf("%lld %lld %lld", &r, &d, &x);

    for (i = 1; i < 11; i++)

    {

        x = r * x - d;

        printf("%lld\n", x);

    }

    return 0;

}



Measured memory_bytes: 128
function main(tapDance) {

  const odd = ['R', 'U', 'D'];
  const even = ['L', 'U', 'D'];

  if(tapDance.length === 1){
    if(tapDance === 'L')
      return 'No';
  }
  
  for(var i = 1; i < tapDance.length; i++) {
    if (i % 2 == 1) {
      //奇数番目の処理
      if (odd.indexOf(tapDance[i-1])!==-1) {
        continue;
      } else {
        return 'No';
      }
    } else {
      //偶数番目の処理
      if (even.indexOf(tapDance[i-1])!==-1) {
        continue;
      } else {
        return 'No';
      }
    }
  }
  return 'Yes';
}

console.log(main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n')[0].trim()));


Measured memory_bytes: 7372
#include    <bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,a,b) for(int i=(a);i>=(b);--i)
#define rep(i,a,b)  for(int i=(a);i<(b);++i)
#define fi  first
#define se  second
#define LL  unsigned long long
#define uint unsigned int
#define pb  push_back
#define eb  emplace_back
#define bit(s,i) ((s >> i) & 1)
#define off(s,i) (s & (~ (1 << i)))
#define ii pair <int , int>
#define iii1 pair <ii , int>
#define iii2 pair <int , ii>
#define TASK "F-SHUFFLING"
using   namespace   std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const int oo = 0x3f;
const int base = 1e9 + 7;
int n , m , a[3010] , up[3010] , f[3010][3010];
string s;
///--------------------------
void readf() {
    cin >> n >> m >> s;
    s = " " + s;
    for (int i = 1 ; i <= n ; ++i)
    a[i] = a[i-1] + (s[i] == '1');
}
///--------------------------
void solve() {
    for (int i = 1 ; i <= m ; ++i) {
        int u , v;
        cin >> u >> v;
        up[u] = max(up[u],v);
    }
    f[0][0] = 1;
    for (int i = 1 ; i <= n ; ++i) {
        up[i] = max({up[i] , up[i-1] , i});
        if (a[up[i]] < up[i] - i + 1) f[i][0] = f[i-1][0];
        for (int j = 1 ; j <= i ; ++j) {
            if (a[up[i]] - j < up[i] - i + 1) f[i][j] = (f[i][j] + f[i-1][j]) % base;
            if (a[up[i]] - j >= 0) f[i][j] = (f[i][j] + f[i-1][j-1]) % base;
        }
    }
    cout << (f[n][a[n]] % base + base) % base;
}
///--------------------------
int main() {
   #ifdef BDP0509
       freopen(TASK".inp", "r", stdin);
       freopen(TASK".out", "w", stdout);
   #endif // ONLINE_JUDGE
   ios::sync_with_stdio(0);
   cin.tie(0);cout.tie(0);
   readf();
   solve();
}



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

int main(void)
{
    int a,b,t,x;
    cin >> a >> b >> t;
    if (a>t){
        cout << 0 << endl;
        exit(0);
    }
    x=(t-(t%a))/a;
    cout << x*b << endl;



}

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

int main() {
    int n; cin >> n;
    unordered_map<int,int> mp;
    for(int i=0; i<n-1; i++){
        int e; cin >> e;
        mp[e]++;
    }
    for(int i=0; i<n; i++){
        if(mp.find(i+1) != mp.end())
            cout << mp[i+1] << endl;
        else
            cout << 0 << endl;
    }
}

Measured memory_bytes: 11372
#include <iostream>
#include <iomanip>
using namespace std;
 
int main(){
    int n=0,i=0;
    long int tmp=0;
    long int max = -9000000;
    long int min = 9000000;
    long int sum =0;
    cin >> n;

    for(i=0;i<n;i++){
    	cin >> tmp;
    	sum += tmp;

    	if(max<tmp){
    		max = tmp; 
    	}
    	if(min>tmp){
    		min = tmp;
    	}
    }
    cout << min << " " << max << " " << sum << endl;

return 0;
}

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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

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


int main()
{
    string s;
    cin >> s;
    reverse(all(s));
    int n = sz(s);
    vector<int> a(n + 1);
    map<int, int> cnt;
    a[0] = 0;
    cnt[0] = 1;
    ll ans = 0;
    for (int i = 0, pw = 1; i < n; ++i, pw = (pw * 10) % 2019) {
        int x = a[i] + (s[i] - '0') * pw;
        x %= 2019;
        ans += cnt[x];
        a[i + 1] = x;
        ++cnt[x];
    }
    cout << ans;
}


Measured memory_bytes: 4336
#include<cmath>
#include<vector>
#include<iostream>
using namespace std;
#define df 0
int divup(int a,int b){return (a+b-1)/b;}
int pow(int a){return a*a;}

void add(int l,int r,vector<int>& imos){
  // [l,r]
  if(df)printf("add %d %d\n",l,r);
  imos.at(l)++;
  imos.at(r+1)--;
}
void add(int a,vector<int>& imos){
  // [a,a]
  if(df)printf("add %d\n",a);
  imos.at(a)++;
  imos.at(a+1)--;
}


void f(int l,int r,vector<int>& imos){
  int len=r-l+1;
  add(1,len,imos);
  int q0=divup(l,len+1);
  add(max(len+1,divup(l,q0)),r/q0,imos);
  for(int q=q0-1;q>0;q--){
    add(divup(l,q),r/q,imos);
  }
}

void g(int l,int r,vector<int>& imos){
  int len=r-l+1;
  for(int q=1;q<len;q++){
    add(divup(l,q),r/q,imos);
    add(q,imos);
  }
  if(df)printf("sq:%d\n",(int)(sqrt(l-0.5)));
  for(int q=len,sq=sqrt(l-0.5); q<=sq;q++){
    if(divup(l,q)==r/q){
      add(r/q,imos);
      add(q,imos);
    }
  }
  if(df)printf("sq:%d\n",(int)(sqrt(r+0.5)));
  if(l<=(pow((int)(sqrt(r+0.5))))){
    add((int)(sqrt(r+0.5)),imos);
  }
}

int main(){
  if(df) printf("*debug mode*\n");
  int n,m; cin >>n >>m;
  vector<int> imos(m+2,0);
  for(int i=0;i<n;i++){
    int l,r; cin >>l >>r;
    long int len=r-l+1;
    if(len*len>r) f(l,r,imos);
    else g(l,r,imos);
  }
  int sum=0;
  for(int i=1;i<=m;i++){
    sum+=imos.at(i);
    printf("%d\n",sum);
  }
}

/// confirm df==0 ///


Measured memory_bytes: 1280
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;

//#define EVEL 1

#ifndef EVEL00
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif


int N;
int A[100010];
lli SUM, ans;

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

	cin >> N;
	for(int i = 1; i <= N; i++){
		cin >> A[i];
		SUM += std::abs(A[i]-A[i-1]);
	}
	SUM += std::abs(A[N]-A[0]);
	for(int i = 1; i <= N; i++){
		cout << SUM + std::abs(A[i+1]-A[i-1]) - std::abs(A[i]-A[i-1]) - std::abs(A[i+1]-A[i])<< "\n";
	}

	return 0;
}


Measured memory_bytes: 1664
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}          // Least Commont Multiple オーバーフローしないように先に割る

const ll INF = LONG_MAX;
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()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("a.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    string s;
    cin >> s;
    if (s == "Sunny")
    {
        cout << "Cloudy";
    }
    else if (s == "Cloudy")
    {
        cout << "Rainy";        
    }
    else
    {
        cout << "Sunny";        
    }

    return 0;
}

/*
  - 1e9 : 10^9
  - vector
    vector<int> A(N);
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  ll n ; cin>> n ;
  ll sum =0 ;
  rep(i,n-1){
    ll a,b ; cin>>a>>b ;
    if(a>b) swap(a,b) ;
    sum += a* (n-b+1) ;
  }
  ll ans= n*n*(n+1)/2 - (n-1)*n*(2*n-1)/6 - (n-1)*n/2 -sum ;
  cout<< ans<< endl ;
 return 0 ; 
}



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

void solve()
{
    int n; cin >> n;
    ll bil = 0;
    while(1)
    {
        if(bil >= n)
        {
            break;
        }
        bil += 1000;
    }
    cout << bil -n << endl;
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3628
import sys
from collections import Counter
def input(): return sys.stdin.readline().rstrip()
# ----------------------------------------------------------- #

n = int(input())
A = list(int(x) for x in input().split())
A.sort()
counter = Counter(A)
ans = 0
cache = set()
for a in A:
    if a in cache:
        continue
    tmp = a
    while tmp <= 10**6:
        cache.add(tmp)
        tmp += a
    if counter[a] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 180092
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define int long long
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MAXIN(x) max_element(ALL(x)) - x.begin();
#define MIN(x) *min_element(ALL(x))
#define MININ(x) min_element(ALL(x)) - x.begin();
#define INF 1000000000000
#define MOD 1000000007

#define MAXR 100000
#define PI 3.14159265358979323846

int divisor(int64_t n) {
    vector<int64_t> ret;
    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret.size();
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

using namespace std;

signed main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = n-1; i > 0; i--) {
        long long N;
        N = i;
        const auto &pf = prime_factorize(N);
        long long res = 1;
        for (auto p : pf) res *= p.second + 1;
        ans += res;
    }

    
    cout << ans <<endl ;

    return 0;
}

Measured memory_bytes: 3628
tmp=input().split(" ")
a = int(tmp[0])
b = int(tmp[1])
k = int(tmp[2])

count=0
for n in range(max(a,b), 0, -1):
    if a % n == 0 and b % n == 0:
        count += 1
        if count == k:
            print(n)
            exit()


Measured memory_bytes: 3060
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n     ] = put n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStr n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

main = do
  [x] <- readInteger
  let (a, b) = x `divMod` 11 in let c = f b in print $ a * 2 + c


f b | b == 0    = 0
    | b > 6     = 2
    | otherwise = 1


Measured memory_bytes: 380
#include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define Rep(i, n) for (int i = int(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { lint to, cost; };
using P = pair<lint, lint>;
using D = pair<double, double>;
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3e18;

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

lint modpow(lint x, lint n) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

lint gcd(lint a, lint b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }

bool pri(lint p) {
	for (lint i = 2LL; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1LL;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }


int main() {
	int n; string s;
	cin >> n >> s;
	if (n & 1) cout << "No\n";
	else if (s.substr(0, n / 2) == s.substr(n / 2)) cout << "Yes\n";
	else cout << "No\n";
}

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


int main() {
  long n;
  cin >> n;
  int ans=0;
  vector<bool>a(1001001,true);
  
  a.at(0)==false;
  a.at(1)==false;
  
  
  rep2(i,2,1001001){
    if(a.at(i)){
      for(int j=i*2;j<1001001;j+=i){
        a.at(j)=false;
      }
    }
  }
  vector<int>co(1001001);
  long m=n;
  for (long i = 2; i*i <= n; ++i){
    if(a.at(i)){
      while(m%i==0){
        co[i]++;
        m/=i;
      }
    }
  }
  rep(i,co.size()){
    int c=0;
    int j=0;
    int a=0;
    while(j<=co[i]){
      a++;
      j=a*(a+1)/2;
      c++;
    }
    ans+=c-1;
    
  }
  bool p=true;
  co[1]=1;
  if(m<1001001){
    if(co[m]>0){
      p=false;
    }
  }
  if(p){
    ans++;
  }
  
      
  cout<<ans<<endl;
  
  
  
}




Measured memory_bytes: 7204
n,m,q=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(q):
  A,B,C,D=map(int,input().split())
  a.append(A)
  b.append(B)
  c.append(C)
  d.append(D)
ans=0
M=[0,0,0,0,0,0,0,0,0,0,0]
for i in range(n):
  M[i]=1
cursor=n
breakflag=0
while True:
  ev=0
  for i in range(q):
    if M[b[i]-1]-M[a[i]-1]==c[i]:
      ev+=d[i]
  if ev>ans:
    ans=ev
  while True:
    if M[cursor-1]<m:
      M[cursor-1]+=1
      for i in range(cursor,n):
        M[i]=M[cursor-1]
      cursor=n
      break
    cursor-=1
    if cursor==0:
      breakflag=1
      break
  if breakflag==1:
    break
print(ans)

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

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

    rep(i, 9){
        if(i*111 < N && N <= (i+1)*111){
            cout << (i+1) * 111 << endl;
        }
    }
}

Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    int ar[200001];

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j,a,b,c,d;
            cin>>n>>a>>b>>c>>d;
            string s;
            cin>>s;
            ar[a]=1;
            for(i=a+1;i<=n;++i)
            {
                if(s[i-1]=='#')
                {
                    ar[i]=0;
                    continue;
                }
                if(ar[i-2]==1 || ar[i-1]==1)
                    ar[i]=1;
                //cout<<i<<"..."<<ar[i]<<endl;
            }
            if(ar[c]==0 || ar[d]==0)
            {
                cout<<"No"<<endl;
                return 0;
            }
            if(c<d)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
            for(i=b;i<=d;++i)
            {
                if(ar[i]==1 && ar[i-1]==1 && ar[i+1]==1)
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
            cout<<"No"<<endl;
        }
        return 0;
    }


Measured memory_bytes: 1360
from collections import Counter
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n=int(input())
c = Counter(prime_factorize(n))
ans=0
N=n
for k,v in c.items():
	x=v
	d=1
	while x-d>=0:
		ans+=1
		x-=d
		d+=1
print(ans)

Measured memory_bytes: 9468
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (100)
#define MAX_K (100000)

int main() {
  // read inputs
  int N, K, as[MAX_N];
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++) {
    scanf("%d", &as[i]);
  }

  // solve dp
  int dps[MAX_K + 1];
  for (int k = 0; k <= K; k++) {
    int dp = 0;
    for (int i = 0; i < N; i++) {
      const int a = as[i];
      if (k - a >= 0 && dps[k - a] == 0) {
        dp = 1;
      }
    }
    dps[k] = dp;
  }
  if (dps[K]) {
    printf("First\n");
  } else {
    printf("Second\n");
  }
}

Measured memory_bytes: 512
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rm()
if a & 1 == b & 1:
  print((a+b)//2)
else:
  print('IMPOSSIBLE')
















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

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

  cin >> a >> b >> c >> d;

  while (true){
    c -= b;
    if (c <= 0){
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if (a <= 0){
      cout << "No" << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
	int i=0,x;
	
	while(1)
	{
		scanf("%d",&x);
		
		if(x==0)
		break;
		i++;
		printf("Case %d: %d\n",i,x);
	}
	
	return 0;
}


Measured memory_bytes: 2004
# AtCoDeer君は、赤、緑、青色のカードを持っています。
# それぞれのカードには 1 以上 9 以下の整数が書かれており、
# 赤色のカードには r、緑色のカードには g、
# 青色のカードには b が書かれています。
# 3つのカードを左から順に赤、緑、青色の順に並べ、
# 左から整数を読んだときにこれが 4の倍数であるか判定しなさい。

# 制約
# 1 ≦ r, g, b ≦ 9

# 標準入力から r, g , b の値を取得する
r, g, b = map(int, input().split())

# 3桁の数値（agbと並べた数値）が 4の倍数かを判定し、結果を出力する
input_rgb = r * 100 + g * 10 + b
result = "ret"

if input_rgb % 4 == 0:
    result = "YES"
else:
    result = "NO"

print(result)


Measured memory_bytes: 9060
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


def main():
    n = int(input())
    d = make_divisors(n)
    p = [d[i:i+2] for i in range(0, len(d), 2)]

    if len(d) % 2 != 0:
        tmp = p[-1]
        p[-1] = tmp + tmp

    arr = []
    for x, y in p:
        arr.append(x+y)

    print(min(arr)-2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3756
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.LinkedHashSet;
import java.util.Set;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(br.readLine());
        Set<String> set = new LinkedHashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(br.readLine());
        }

        br.close();

        bw.write(String.valueOf(set.size()));

        bw.flush();

    }
}

Measured memory_bytes: 66828
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#define lli long long int
#define ALL(x) x.begin(), x.end()
using namespace std;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

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

	vector<pair<int, int>> vec(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		vec[i] = make_pair(a, b);
	}

	sort(ALL(vec), compare_by_b);

	int count = 0;
	for (int i = 0; i < n; i++) {
		count += vec[i].first;
		if (count > vec[i].second) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int gcd(int x, int y) {
	while (1) {
		int r = x % y;
		if (r == 0) break;
		x = y; y = r;
	}
	return y;
}

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

	sort(A.begin(), A.end());
	int ans = gcd(A[0],A[1]);
	for (int i = 2; i < N; i++) {
		ans = gcd(ans,A[i]);
	}

	cout << ans << endl;
}


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

int main() {
  string s;
  cin>>s;
  int n=s.size();
  int ans,a,b;
  a=0;
  b=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      if(s[i]=='0') a++;
      else b++;
    }
    else{
      if(s[i]=='0') b++;
      else a++;
    }
  }
  cout<<min(a,b)<<endl; 
}


Measured memory_bytes: 512
from collections import deque
S = input()
Q = int(input())
r = 0
s = deque(S)
for i in range(Q):
    q = input().split()
    if q[0]=='1':
        r += 1
    else:
        f = int(q[1])
        f += r
        f %= 2
        if f==0:
            s.append(q[2])
        else:
            s.appendleft(q[2])
ans = ''.join(s)
if r%2==1:
    ans = ans[::-1]
print(ans)

Measured memory_bytes: 76632
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[]args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int H=0;
		int W=0;
		String[] arr;
		while((str=br.readLine())!=null){
			arr=str.split(" ");
			H=Integer.parseInt(arr[0]);
			W=Integer.parseInt(arr[1]);
			if((H==0)&&(W==0)){
				break;
			}
			for(int i=1;i<=H;i++){
				for(int j=1;j<=W;j++){
					if((i%2)!=0){
						if((j%2)!=0){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
					}
					else {
						if((j%2)!=0){
							System.out.print(".");
						}else{
							System.out.print("#");
						}
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
		br.close();
	}
}

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

int main(){
    vector<int> A(3);
    for (int i; i<3; i++){
        cin >> A.at(i);
    }
    std::sort(A.begin(),A.end());
    cout<< A.at(2) - A.at(0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;

int main(void){
    long N,M;
    long X,Y;
    cin>>N>>M>>X>>Y;
    for(int i=0;i<N;i++){
        long x;
        cin>>x;
        X=max(x,X);
    }
    
    for(int i=0;i<M;i++){
        long y;
        cin>>y;
        Y=min(y,Y);
    }
    
    if(X<Y) cout<<"No War"<<endl;
    else cout<<"War"<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  ll ans=0;
  for(ll i=1;i<=sqrt(n);i++){
    if(n%i==0){
      ll p=n/i;
      ll m=max(p,i);
      ll u=min(p,i);
      if(m-1>u){
        ans+=m-1;
      }
    }
  }
  COUT(ans);
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100

int main(void) {
	int n;
	int stus[N][N];
	int left_height[N];
	int right_height[N];
	int i;
	int j;
	int end;

	while (1) {
		scanf("%d",&n);
		if (n == 0) {
			break;
		}
		for (i = 0;i < n;++i) {
			for (j = 0;j < n;++j) {
				scanf("%d",&stus[i][j]);
			}
		}
		for (i = 0;i < n;++i) {
			left_height[i] = stus[i][0];
			right_height[i] = stus[0][i];
		}
		for (i = 0;i < n;++i) {
			for (j = 0;j < n;++j) {
				if (stus[i][j] < left_height[i]) {
					left_height[i] = stus[i][j];
				}
				if (stus[i][j] > right_height[j]) {
					right_height[j] = stus[i][j];
				}
			}
		}
		end = 0;
		for (i = 0;i < n;++i) {
			for (j = 0;j < n;++j) {
				if (left_height[i] == right_height[j]) {
					printf("%d\n",left_height[i]);
					end = 1;
					break;
				}
			}
			if (end) {
				break;
			}
		}
		if (!end) {
			printf("0\n");
		}
	}
	return 0;
}

Measured memory_bytes: 616