akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split())

if H % 3 == 0 or W % 3 == 0:
    print(0)
    exit()
else:
    cand = []
    for i in range(1, H):
        # 横に分割
        S1 = i * W
        S2 = (H - i) * (W // 2)
        S3 = (H - i) * (W - W // 2)
        cand.append(max(S1, S2, S3) - min(S1, S2, S3))
        # 縦に分割
        S2 = (H - i) // 2 * W
        S3 = ((H - i) - (H - i) // 2) * W
        cand.append(max(S1, S2, S3) - min(S1, S2, S3))
    for i in range(1, W):
        # 横に分割
        S1 = i * H
        S2 = (W - i) * (H // 2)
        S3 = (W - i) * (H - H // 2)
        cand.append(max(S1, S2, S3) - min(S1, S2, S3))
        # 縦に分割
        S2 = (W - i) // 2 * H
        S3 = ((W - i) - (W - i) // 2) * H
        cand.append(max(S1, S2, S3) - min(S1, S2, S3))
    print(min(cand))

Measured memory_bytes: 18960
#include <bits/stdc++.h>
 
using namespace std;
 
int dp[2][3];
 
int main(){
    int n; cin >> n;
    int linha[5];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            cin >> linha[j];
            if(i == 0) dp[0][j] = linha[j];
            else {
                for(int k = 0; k < 3; k++){
                    if(k == j) continue;
                    dp[1][j] = max(dp[1][j], linha[j] + dp[0][k]);
                }
            }
        }
        if(i){
            for(int j = 0; j < 3; j++){
                // cout << i << ": " << dp[1][j] << " ";
                dp[0][j] = dp[1][j];
                dp[1][j] = 0;
            } cout << endl;
        }
    }
    int res = 0;
    for(int i = 0; i < 3; i++) res = max(res, dp[0][i]);
    cout << res << endl;
    
    return 0;
}

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

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

    for (int i = 0; i <= N; i++) {
        ll one = 1e4 * i;

        if (one == Y && i == N) {
            cout << i << ' ' << 0 << ' ' << 0 << "\n";
            return 0;
        }

        for (int j = 0; i+j <= N; j++) {
            ll two = j * 5e3;

            ll three = (N - (i+j)) * 1e3;

            if (one + two + three == Y) {
                cout << i << ' ' << j << ' ' << N-(i+j) << "\n";
                return 0;
            }
        }
    }

    cout << -1 << ' ' << -1 << ' ' << -1 << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;
signed main(){
  int n,m;
  cin >> n >> m;
  vint A(n);
  rep(i,n) cin >> A[i];
  sort(A.begin(),A.end());
  vector<P> card(m);
  rep(i,m){
    int b,c;
    cin >> b >> c;
    card[i] = make_pair(c,b);
  }
  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());
  int count = 0;
  int nowcard = 0;
  int nowcardcount = 0;
  int now = 0;
  while(nowcard < m){
    if(card[nowcard].first > A[now]){
      A[now] = card[nowcard].first;
      nowcardcount++;
      if(nowcardcount == card[nowcard].second){
        nowcard++;
        nowcardcount = 0;
      }
      now++;
    }
    else break;
  }
  int sum = 0;
  rep(i,n) sum += A[i];
  cout << sum << endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

public static void main(String[] args){

	Scanner scanner = new Scanner(System.in);

	int a = scanner.nextInt();
	int b = scanner.nextInt();

	if( a > b ){
	System.out.println("a > b");
	}
	else if ( a < b ){
	System.out.println("a < b");
	}
	else if ( a == b ){
		System.out.println("a == b");
	}
  }
}

Measured memory_bytes: 26176
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
#define MAX 200000

int main()
{
	int a;
	int count = 0;
	int result=1;
	cin >> a;

	while (a != 1)
	{
		a = a / 2;
		count++;
	}

	//cout << count;

	for (int i = 0; i < count; i++)
	{
		result = result * 2;
	}


	cout << result;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;
typedef unsigned int uint;

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

	int s;
	cin >> s;

	cin.setf(ios::hex, ios::basefield);
	cout.setf(ios::hex, ios::basefield);
	while(s--) {
		vector<uint> N(9);
		for(int i = 0; i < 9; i++) {
			cin >> N[i];
		}
		uint K = 0;
		for(int i = 0; i < 32; i++) {
			int cnt = 0;
			for(int j = 0; j < 8; j++) {
				cnt += N[j] ^ K;
			}
			if((cnt & (1 << i)) != (N[8] & (1 << i))) {
				K |= 1 << i;
			}
		}
		cout << K << endl;
	}
}

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


Measured memory_bytes: 2060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res){
    ll N,A,B; cin >> N >> A >> B;
    ll minv,maxv;
    if((N>=2) && (A <= B)){
        minv = A*(N-1) + B;
        maxv = A + B*(N-1);
        res = maxv - minv + 1;
    }else if((N==1) && (A==B)){
        res = 1;
    }else{
        res = 0;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve(0LL) << endl;
    return 0;
}


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

using namespace std;

int main(){

   long long int n;
   string ans = "";

   cin >> n;

   for(;n;){
      n--;
      int mod = n % 26;
      n /= 26;
      ans = (char)('a' + mod) + ans;

      if(!mod && n == 1){
         ans = "a" + ans;
         break;
      }
   }

   cout << ans << endl;

   return 0;
}

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

int main()
{
  int n;
  int l[201];
  cin >> n;
  for (int i = 0; i < 2*n; i++)
    cin >> l[i];
  
  sort(l, l + 2*n);
  
  int sum = 0;
  for (int i = 0; i < 2*n; i+=2)
    sum += l[i];
  
  cout << sum << endl;
}
    

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i=0; i<H; i++) cin >> S[i];
  vector<vector<int>> c(H, vector<int>(W));
  int m = 0;
  for(int y=0; y<H; y++){
    int s=0;
    for(int x=0; x<W; x++){
      if(S[y][x]=='#') s=0;
      else{
        c[y][x]=1+s;
        s++;
      }
    }
    s=0;
    for(int x=W-1; x>=0; x--){
      if(S[y][x]=='#') s=0;
      else{
        c[y][x]+=s;
        s++;
      }
    }
  }
  for(int x=0; x<W; x++){
    int s=0;
    for(int y=0; y<H; y++){
      if(S[y][x]=='#') s=0;
      else{
        c[y][x]+=s;
        s++;
      }
    }
    s=0;
    for(int y=H-1; y>=0; y--){
      if(S[y][x]=='#') s=0;
      else{
        c[y][x]+=s;
        s++;
      }
      m = max(m, c[y][x]);
    }
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 20096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int menseki = (a + b) * h / 2;
		System.out.println(menseki);
	}

}

Measured memory_bytes: 26988
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N;
    scan(N);
    auto a = readln.split.to!(int[]);
    auto b = readln.split.to!(int[]);

    foreach (i ; 0 .. N) {
        if (a[i] != b[i] && b[i] >= (a[i] + 1) / 2) {
            writeln(-1);
            return;
        }
    }

    // dp(x, y, i) = 1 ~ i を使って x を y にできるか
    auto dp = new bool[][][](51, 51, 51);
    foreach (i ; 0 .. 51) {
        dp[i][i][0] = true;
    }

    foreach (i ; 1 .. 51) {
        foreach (x ; 0 .. 51) {
            foreach (y ; 0 .. 51) {
                dp[x][y][i] = dp[x][y][i - 1] || dp[x % i][y][i - 1];
            }
        }
    }
    

    auto s = new long[](N);
    foreach (i ; 0 .. N) {
        s[i] = 1L << a[i];
    }

    long ans;

    foreach_reverse (k ; 1 .. 51) {
        bool use;

        foreach (i ; 0 .. N) {
            bool ok;
            foreach (j ; 0 .. 51) if (s[i] & 1L << j) {
                ok |= dp[j][b[i]][k - 1];
            }
            if (!ok) {
                use = true;
                break;
            }
        }

        if (!use) continue;

        ans += 1L << k;
        foreach (i ; 0 .. N) {
            foreach (j ; 0 .. 51) if (s[i] & 1L << j) {
                s[i] |= 1L << (j % k);
            }
        }
    }

    debug {
        writefln("%b", ans);
    }
    writeln(ans);
}






void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  ll k,a,b;
  
  cin >> k >> a >> b;
  
  if (a>b){
    cout << (k-b-1)/(a-b)*2+1 << endl;
  }else{
    if (k<=a){
      cout << 1 << endl;
    }else{
      cout << -1 << endl;
    }
  }
  
  return 0;
}

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

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

  int n;
  cin >> n;
  vector<int> w(n), acum(n), acumr(n);
  rep(i, 0, n) cin >> w[i];

  int sum_val = accumulate(w.begin(), w.end(), 0);
  int num = 0, ans = 1e9;
  rep(i, 0, n - 1) {
    num += w[i];
    ans = min(ans, abs(num - (sum_val -num)));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct node{
    int x,y;
    bool operator<(const node &b)const {
        return y<b.y;
    }
}q[100005];
bool cmp(node a,node b){
    return a.x<b.x;
}
priority_queue<node> p;
int n,m;
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>m;node tmp;
    for(int i=1;i<=n;i++){
        cin>>q[i].x>>q[i].y;
    }
    sort(q+1,q+1+n,cmp);
    int ans=0;int now=1;
    for(int i=1;i<=m;i++){
        while (now<=n&&q[now].x<=i){p.push(q[now]);now++;}
        if(p.size()) {
            ans += p.top().y;
            p.pop();
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2168
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        for(int i = 0;i<n;i++) sum += sc.nextInt()-1;
        System.out.println(sum);
    }
}


Measured memory_bytes: 27872
#include<bits/stdc++.h>
using namespace std;
int f[100005],g[100005],n,x;
int main()
{
	cin>>n;
	for (int i=1;i<=n;++i)
	{
		cin>>x;
		if (i&1)
			f[++f[0]]=x;
		else
			g[++g[0]]=x;
	}
	if (n&1)
	{
		for (int i=f[0];i;--i)
			cout<<f[i]<<' ';
		for (int i=1;i<=g[0];++i)
			cout<<g[i]<<' ';
	}
	else
	{
		for (int i=g[0];i;--i)
			cout<<g[i]<<' ';
		for (int i=1;i<=f[0];++i)
			cout<<f[i]<<' ';
	}
}

Measured memory_bytes: 2944
#include <stdio.h>
int main () {
	char tahun[15];
	scanf("%s", tahun);
	
	tahun [0] = '2';
	tahun [1] = '0';
	tahun [2] = '1';
	tahun [3] = '8';
	
	printf("%s", tahun);
	
	return 0;
}

Measured memory_bytes: 1680
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      if(a>b){
        if(b<c && c<a){
           System.out.println("Yes");
        }else{
          System.out.println("No");
        }
      }else{
        if(a<c && c<b){
           System.out.println("Yes");
        }else{
          System.out.println("No");
        }
      }
    }
}

Measured memory_bytes: 35528
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

ll a[100010];
int main()
{
	int N;
	ll L;
	cin >> N >> L;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int last;
	bool ok = false;
	for (int i = 0; i < N - 1; i++) {
		if (a[i] + a[i + 1] >= L) {
			last = i;
			ok = true;
			break;
		}
	}
	if (!ok) {
		cout << "Impossible" << endl;
	}
	else {
		cout << "Possible" << endl;
		for (int i = 0; i < last; i++) {
			cout << i + 1 << endl;
		}
		for (int i = N - 2; i > last; i--) {
			cout << i + 1 << endl;
		}
		cout << last + 1 << endl;
	}
}



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

#define fr first
#define sc second
#define pii pair < int, int >

const int N = 1e5;
int dp[N + 1], h[N + 1];

#define name "lifeguards"

main()
{
	//freopen(name".in", "r", stdin);
	//freopen(name".out", "w", stdout);
	int n; cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> h[i];
	
	dp[2] = abs(h[2] - h[1]);
	for(int i = 3; i <= n; i++)
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	
	cout << dp[n] << endl;
}
/***
***/


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		System.out.println("" + s.charAt(0) + (s.length() - 2 ) + s.charAt(s.length() - 1));

		return;
	}

}


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

ll solve(ll n,ll d,ll s){
	if(n<=d)return s+n;
	return solve(n/d,10,s+n%d)+solve(n,d*10,s);
}

int main(void){
	ll n;
	cin>>n;
	cout<<solve(n,10,0)<<endl;
	return 0;
}


Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())
if x>=y:
    res = min([2*x*c, 2*y*c+a*(x-y), a*x+b*y])
else:
    res = min([2*y*c, 2*x*c+b*(y-x), a*x+b*y])
print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
#define mod 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
int main(){
  string S; cin>>S;
  int N = S.size();
  int wnum = 0;
  ll ans = 0;
  for(int i=N;i>=0;i--){
    if(S[i]=='W') wnum++;
    else ans+=wnum;
  }
  cout<<ans<<endl;

  return 0;
}


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

namespace Atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int n =int.Parse( Console.ReadLine());
            var words = new List<string>();
            for (int i = 0; i < n;i++){
                words.Add(Console.ReadLine());
                if(i!=0){
                    string last = words[i - 1].Substring(words[i - 1].Length - 1,1);
                    string top = words[i].Substring(0, 1);

                    for (int j = 0; j < words.Count - 1; j++)
                    {
                        if (words[j]==words[i] || last != top)
                        {
                            
                            Console.WriteLine("No");
                            return;
                        }
                    }
                }
            }
            Console.WriteLine("Yes");
         }
     }
}




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

int main()
{
    int m, f, r, n = 0;
    char test_scores[50] = {};

    for (int i = 0;; i++)
    {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1)
        {
            break;
        }
        n++;

        if (m == -1 || f == -1)
        {
            test_scores[i] = 'F';
        }
        else if (80 <= (m + f))
        {
            test_scores[i] = 'A';
        }
        else if (65 <= (m + f) && (m + f) < 80)
        {
            test_scores[i] = 'B';
        }
        else if (50 <= (m + f) && (m + f) < 65)
        {
            test_scores[i] = 'C';
        }
        else if (30 <= (m + f) && (m + f) < 50)
        {
            test_scores[i] = 'D';
            if (50 <= r)
            {
                test_scores[i] = 'C';
            }
        }
        else if ((m + f) < 30)
        {
            test_scores[i] = 'F';
        }
    }

    for (int i = 0; i < n; i++)
    {
        cout << test_scores[i] << endl;
    }
}



Measured memory_bytes: 3088
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;



int main() {
    int x;
    cin>>x;
    if(x==3||x==5||x==7)puts("YES");
    else puts("NO");

    return 0;
}

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

using namespace std;

const int MAX_N = 200001;

int N, M, mark[MAX_N];
unordered_set<int> edges[MAX_N];

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

  cin >> N >> M;
  for(int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    edges[a].insert(b);
    edges[b].insert(a);
  }

  int ans = 0;
  for(int i = 1; i <= N; ++i) {
    if(mark[i]) continue;
    int cnt = 0;
    queue<int> q;
    mark[i] = i;
    ++cnt;
    q.push(i);
    while(!q.empty()) {
      int u = q.front(); q.pop();
      for(int v: edges[u]) {
        if(mark[v]) continue;
        mark[v] = i;
        ++cnt;
        q.push(v);
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << "\n";
  return 0;
}

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

int main()
{
	char s[100001];
	char t[100001];
	scanf("%s%s", s, t);
	int i;
	int scount = 0;
	char* ps = s;
	char* ret;
	for (i = 0; i < strlen(t); i++) {
		if (strchr(s, t[i]) == NULL) {
			printf("-1\n");
			return 0;
		}
		ret = strchr(ps, t[i]);
		if (ret == NULL) {
			ret = strchr(s, t[i]);
			scount++;
		}
		ps = ret+1;
		if (*ps == '\0') {
			ps = s;
			scount++;
		}
	}
	long ans;
	ans = (long)strlen(s) * (long)scount + (ps - s);
	printf("%ld", ans);
	return 0;
}

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

int main()
{
	int a,b;
	cin >> a >> b;
	if (a < b) {
		cout << "a < b\n";
	}
	else if (a > b) {
		cout << "a > b\n";
	}
	else {
		cout << "a == b\n";
	}
    return 0;
}




Measured memory_bytes: 3048
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int h, w;
    while (cin >> h >> w, h + w) {
        vector<vector<char>> spell(h, vector<char>(w));
        REP (i, 0, h) REP (j, 0, w) cin >> spell[i][j];
        map<string, int> ml;
        REP (i, 0, h) REP (j, 0, w) {
            REP (dy, -1, 2) REP (dx, -1, 2) {
                if (dx == 0 && dy == 0) continue;
                vector<vector<bool>> isAccess(h, vector<bool>(w, false));
                int y = i, x = j;
                string temp = "";
                REP (_, 0, w * h) {
                    if (isAccess[y][x]) break;
                    isAccess[y][x] = true;
                    temp += spell[y][x];
                    ml[temp]++;

                    y = (y + dy + h) % h;
                    x = (x + dx + w) % w;
                }
            }
        }
        string ans = "";
        for (auto s : ml) {
            if (s.second <= 1 || s.first.size() <= 1) continue;
            if (ans.size() < s.first.size()) ans = s.first;
            else if (ans.size() == s.first.size()) ans = min(ans, s.first);
        }
        cout << (ans.size() == 0 ? "0" : ans) << endl;

    }
    return 0;
}

Measured memory_bytes: 37828
#include<bits/stdc++.h>
#define ll long long
#define debug(x) cout<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
const int inf=0x3f3f3f3f;
const int maxn=2e6+10;
int main()
{
   ll l;
   cin>>l;
   double ans=l*1.0/3;
   printf("%.12f",ans*ans*ans);
   //system("pause");
   return 0;
}


Measured memory_bytes: 256
package com.example.alds1.Five

import java.util.*

fun main(args: Array<String>) {
    try {
        val sc = Scanner(System.`in`)
        val n = Integer.parseInt(sc.nextLine())
//        val s = sc.nextLine().split(" ").map { Integer.parseInt(it) }.toIntArray()
        val s = IntArray(n)
        for (i in 0 until n) {
            s[i] = sc.nextInt()
        }
        if (n > 500_000 || s.size > 1_000_000_000 || n != s.size) {
            throw Exception("Illegal input")
        }
        val c = mergeSort(s, 0, s.size)
        println(s.joinToString(" "))
        println(c)
    } catch (e: Exception) {
        println(e)
    }
}

fun mergeSort(a: IntArray, left: Int, right: Int): Int {
    var c = 0
    if (left + 1 < right) {
        val mid = (left + right) / 2
        c += mergeSort(a, left, mid)
        c += mergeSort(a, mid, right)
        c += merge(a, left, mid, right)
    }
    return c
}

fun merge(a: IntArray, left: Int, mid: Int, right: Int): Int {
    val n1 = mid - left
    val n2 = right - mid
    val l = IntArray(n1)
    val r = IntArray(n2)
    for (i in 0 until n1) {
        l[i] = a[left + i]
    }
    for (i in 0 until n2) {
        r[i] = a[mid + i]
    }
    var i = 0
    var j = 0
    var c = 0
    for (k in left until right) {
        if (j >= r.size || (i < l.size && l[i] <= r[j])) {
            a[k] = l[i++]
        } else {
            a[k] = r[j++]
        }
        c++
    }
    return c
}



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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  int a, b;
  cin >> a >> b;
  cout << (b % a == 0 ? a + b : b - a) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
   public static void main(String[] args){
     Scanner scanner = new Scanner(System.in);
     int a = scanner.nextInt();
     int b = scanner.nextInt();
     int x=a*b;
     int y=2*a+2*b;
     
       System.out.println(x+" "+y);
      
   }   
}

Measured memory_bytes: 25980
#include<bits/stdc++.h>
using namespace std;
int d[100001][13];
void f(int i,int j,int k)
{
  d[i+1][k%13]+=d[i][j];
  d[i+1][k%13]%=1000000007;
}
int main()
{
  string s;
  cin>>s;
  d[0][0]=1;
  for(int i=0;i<s.size();i++)
    for(int j=0;j<13;j++)
    {
    	if(s[i]=='?')
    	  for(int k=0;k<10;k++)
    	  {
    	  	f(i,j,j*10+k);
          }
        else
          f(i,j,j*10+s[i]-'0');
	}
  cout<<d[s.size()][5];
  return 0;
}

Measured memory_bytes: 5504
#include<stdio.h>


int calc(int,int,int);

int main(){
char OPR[2]={'+','-'};
int opr[8][3]={{0,0,0},{0,0,1},{0,1,0},{0,1,1},{1,0,0},{1,0,1},{1,1,0},{1,1,1}};
int buff,sum=0;
scanf("%d",&buff);
int num[4];
num[0]=buff/1000;
num[1]=(buff/100)%10;
num[2]=(buff/10)%10;
num[3]=buff%10;

for (int i = 0; i < 8; i++){
  int j;
  sum = num[0];
  for (j = 0; j < 3; j++)
  {
    sum = calc(sum,num[j+1],opr[i][j]);
  }
  if (sum==7)
  {
    printf("%d%c%d%c%d%c%d=7",num[0],OPR[opr[i][j-3]],num[1],OPR[opr[i][j-2]],num[2],OPR[opr[i][j-1]],num[3]);
    break;
  }
  sum=0;
}

return 0;

}

int calc(int num_1,int num_2,int opr){
  if (opr==0){
    return num_1+num_2;
  }else{
    return num_1-num_2;
  }
}

Measured memory_bytes: 1696
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int a = sc.nextInt();
    if(a>x){
      System.out.println("0");
    }else{
      System.out.println("10");
    }
  }
}


Measured memory_bytes: 22740
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 0) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::map< std::string, ll > mc;

  ll N, M;
  std::cin >> N;
  std::vector< std::string > vs(N);
  for (ll i = 0; i < N; i++) {
    std::cin >> vs[i];
    mc[vs[i]]++;
  }
  std::cin >> M;
  std::vector< std::string > vt(M);
  for (ll i = 0; i < M; i++) {
    std::cin >> vt[i];
    mc[vt[i]]--;
  }

  ll max_val = 0LL;
  for (auto p : mc) {
    max_val = std::max(max_val, p.second);
  }

  print(max_val);

  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)
#define ll long long
#define P pair<int,int>

int main(){
    ll n,d,count=0;
    cin>>n>>d;
    vector<ll> x(n),y(n);
    rep(i,n) cin>>x[i]>>y[i];
    rep(i,n){
        if(x[i]*x[i]+y[i]*y[i]<=d*d) count++;
    }
    cout<<count<<endl;
    return 0;
}

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

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::vector;
using std::string;

int main(){
    long long x,k,d;
    cin >> x >> k >> d;
    x = std::abs(x);
    if(x/d> k){
        x = x - k*d;
    }else{
        k=k-x/d;
		x=x-(x/d)*d;
        if(k % 2 != 0){
            x-=d;
        }
    }
    cout << std::abs(x);
}

Measured memory_bytes: 3560
#include <stdio.h>
#include <string.h>
#define MM 1000000007
long A[1000100];
int main(){

	long int i,j;
	long int x,y,a,b,c;
	long N,M,K,tmp;
	long long sum=0;
	scanf("%ld%ld",&N,&K);
	long low=0,high=0,Num=0;
	for(i=0;i<K;i++){
		low+=i;
		high+=N-i;
	}
	//printf("%ld %ld\n",low,high);
	for(i=K;i<=N;i++){
		//min
		Num+=high-low+1;
		if(Num>=MM) Num%=MM;
		low+=i;
		high+=N-i;
		//printf("%ld %ld\n",low,high);
	}
		Num+=high-low+1;
		if(Num>=MM) Num%=MM;	
	printf("%ld\n",Num);

	return 0;
}


Measured memory_bytes: 1732
# https://beta.atcoder.jp/contests/abc085/tasks/abc085_d

def solve():
    n, m = map(int, input().split())
    # n, m = 4, 1000000000
    # swing, throw = [1, 1, 1, 1], [1, 10000000, 99999999, 30000000]
    swing, throw = [], []
    for _ in range(n):
        a, b = map(int, input().split())
        swing.append(a)
        throw.append(b)
    swing = sorted(swing)
    throw = sorted(throw)
    max_swing = swing[-1]
    will_throw = [x for x in throw if x > max_swing]

    all_damage = sum(will_throw)
    answer = len(will_throw)
    if all_damage > m:
        for damage in will_throw:
            if all_damage - damage < m:
                print(answer)
                return
            else:
                all_damage -= damage
                answer -= 1
    else:
        print(answer + ((m - all_damage) + (max_swing - 1)) // max_swing)
        return

solve()

Measured memory_bytes: 12080
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
    int k,a,b; cin >> k >> a >> b;
    if(a<=(b-b%k)) cout << "OK" << endl;
    else cout << "NG" << endl;
}

/*
Ctrl+@ でコンソールを開け、以下で実行。
g++ a.cpp
./a.out

サンプルのダウンロードは oj d URL
テストは oj t
コード変えたらコンパイルする
不正解ならWAが出る
*/


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,ans=1;
    cin>> n;
    
    for(int i = 1; i*i <= n; i++)
    {
        ans=i*i;
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Solver{

    private final int L;
    private final int R;

    Solver(Scanner in){
        L = in.nextInt();
        R = in.nextInt();
    }

    void solve(){
        if(R - L >= 2019){
            System.out.println(0);
            return;
        }
        int l = L % 2019;
        int r = R % 2019;
        int min = 2019;
        for(int i = l; i <= r; i++){
            for(int j = i + 1; j <= r; j++){
                min = Math.min(min, i * j % 2019);
            }
        }
        System.out.println(min);
    }
}

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

        new Solver(in).solve();

        in.close();
    }
}

Measured memory_bytes: 25172
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N, Y;
  cin >> N >> Y;
  ll sen = Y / 1000;
  ll gosen = 0;
  ll manen = 0;
  ll total = sen;
  while (total >= N + 4 && sen >= 5) {
    sen -= 5;
    gosen++;
    total -= 4;
  }
  while (total > N && gosen >= 2) {
    gosen -= 2;
    manen++;
    total--;
  }

  if (total == N) {
    cout << manen << " " << gosen << " " << sen << endl;
  } else {
    cout << "-1 -1 -1" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
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() {
    int n, x, t; cin >> n >> x >> t;
    cout << (n+x-1) / x * t << endl;
}


Measured memory_bytes: 3592
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Main m = new Main();
    m.exec();
  }

  private void exec() {
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
	
    if (a + b >= c) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 20820
#include <iostream>
#include <string>
#include <vector>
#include <climits>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, k, v[100000];
    while (cin >> n >> k, n) {
        int sum = 0, res = -INT_MAX;
        for (int i=0; i<n; ++i) {
            cin >> v[i];
            sum += v[i] - (k <= i ? v[i-k] : 0);
            res = max(res, (k-1 <= i ? sum : -INT_MAX));
        }
        cout << res << endl;
    }
    return 0;
}

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

#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,l,r) for(int i = l; i <= r; i++)
#define TR(e,x) for(auto e = x.begin(); e != x.end(); e++)
#define DEBUG(x) cout << #x << "=" << x << endl;
#define SHOW1(A,n) { REP(i,n-1) printf("%d ", A[i]); printf("%d\n", A[n-1]); }
#define SHOW2(A,m,n) { REP(i,m) { REP(j,n-1) printf("%d ", A[i][j]); printf("%d\n", A[i][n-1]); } }
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)((x).size())
typedef long long LL;
const int MAXN  = 8e5, INF = ~0U>>1, MOD = ~0U>>1;



int main()
{
#ifdef LOCAL
    //freopen("i.txt", "r", stdin);
    //freopen("o.txt", "w", stdout);
#endif //LOCAL

    int n, ans = 0;
    string str;
    cin >> n >> str;
    for (int i = 1; i <= n-1; i++) {
        string str1 = str.substr(0,i);
        string str2 = str.substr(i);
        int cnt = 0;
        for (int j = 0; j < 26; j++) {
            if (str1.find('a'+j)!=string::npos && str2.find('a'+j)!=string::npos) {
                cnt++;
            }
        }
        ans = max(ans, cnt);
    }
    printf("%d\n", ans);

    return 0;
}


















































































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

int main(){
  
  int n;
  cin >> n;
  
  map<int,int> m;
  
  for(int i = 1;i<=n;i++){
    int a;
    cin >> a;
    m[a] = i;
  }
  
  for(auto i:m){
    cout << i.second << " ";
  }
  return 0;
}

Measured memory_bytes: 5504
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;


int ds[10];
int main(void) {
  REP(i, 5) {
    scanf("%d", &ds[i]);
  }
  int k;
  scanf("%d", &k);
  int res = 0;
  REP(i, 5) REP(j, i) {
    if(abs(ds[i] - ds[j]) <= k) {
    } else {
      ++res;
    }
  }
  puts(res > 0 ? ":(" : "Yay!");
  return 0;
}


Measured memory_bytes: 760
#include<stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
	
	if(H>=y+r && W>=x+r && r<=x && r<=y){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

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

    long long n, ans = 0;
    cin >> n;

    for (long long i = 1; i * i <= n; i++) {
        long long x = n / i;
        long long shift = i - n % x;
        if (shift % i == 0)
            x -= shift / i;
        if (x)
            ans += x * (n / x == i && n % x == i);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
/*
void solve(){
  ll n; cin >> n;
  vector<ll> prime;
  FOR(i,2,(1000006)){
    bool flg = true;
    
    if(flg) prime.push_back(i);
  }
}
*/
/*
void solve(){
  int n; cin >> n; int ans =0;
  if(n<10) {cout << n; return;}
  priority_queue<
      int,                // 要素の型はint
      std::vector<int>,   // 内部コンテナはstd::vector (デフォルトのまま)
      std::greater<int>   // 昇順 (デフォルトはstd::less<T>)
    > qb, qa;
  FOR(i,1,10000000){
    string s = std::to_string(i);
    bool flg=true;
    FOR(j,0,s.size()-1){
      if(abs(s[j]-s[j+1])>1) {flg=false; break;}
    }
    if(flg) ans++;
    if(ans==n) {cout << i; return;}
  }
  cout << ans << endl;
}*/
/*
void solve(){
  int n, k, c; cin >> n >> k >> c;
  string s; cin >> s;
}*/
template <class T> std::vector<T> divisors(const T &n) {
  std::vector<T> ret;
  T i = static_cast<T>(1);
  while (i * i < n) {
    if (n % i == static_cast<T>(0)) {
      ret.push_back(i);
      ret.push_back(n / i);
    }
    ++i;
  }
  if (i * i == n) {
    ret.push_back(i);
  }
  std::sort(ret.begin(), ret.end());
  ret.shrink_to_fit();
  return std::move(ret);
}


template<class T> struct prime{
  T N;
  vector<T> v;
  void init(const T &n){
    N = n;
    T i = static_cast<T>(2);
    while(true);
  }
};


void solve(){
  ll n; cin >> n;
  size_t ans = 0;
  for (const ll k : divisors(n)) {
    if (k == 1)
      continue;
    ll m = n;
    while (m % k == 0) {
      m /= k;
    }
    if (m % k == 1) {
      ans += 1;
    }
  }
  ans += divisors(n - 1).size();
  std::cout << ans - 1 << std::endl;
}

void solve2(){
  int n, k, c;
  scanf("%d%d%d",&n,&k,&c);
  char *s;
  s = new char[n+10];
  scanf("%s",s);
  vector<int> L(k+5), R(k+5);
  int cnt = 0, bf=-987654321;
  FOR(i,0,n){
    if(s[i]=='o' && (i-bf)>c) {bf = i; L[cnt] = i; cnt++;}
    if(cnt==k) break;
  }
  bf = 987654321; cnt = k-1;
  IFOR(i,0,n){
    if(s[i]=='o' && (bf-i)>c) {bf = i; R[cnt] = i; cnt--;}
    if(cnt==-1) break;
  }
  FOR(i,0,k){
    if(L[i]==R[i])  printf("%d\n",(L[i]+1)) ;
  }
}

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

Measured memory_bytes: 3200
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n >> m;
  assert(2 * m + 1 <= n);

  ll cur = n - 1;
  vll lst;
  while (cur > 0) {
    lst.push_back(cur);
    ll del = abs(cur - (n - cur));
    if (cur > (n-cur) && (del == 2 || del == 4)) cur--;
    cur -= 2;
  }

  rep(i, m) {
    cout << i + 1 << " " << i + 1 + lst[i] << endl;
    //cout << i + 1 << " " << i + 1 + lst[i] << "..." << lst[i] << ", "
    //     << n - lst[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 4124
import math

a,b,n=map(int,input().split())
num=-100
i=1
if n<b:
    num=max(num,math.floor(a*n/b)-a*math.floor(n/b))
else:
    j=b-1
    num=max(num,math.floor(a*j/b)-a*math.floor(j/b))
print(num)


Measured memory_bytes: 62096
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

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


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);

int N,K;
  cin>>N>>K;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  int sum=0;
  vsort(vec);
  
  for(int i=0;i<K;i++){
    sum+=vec[i];
  }
  
  cout<<sum<<endl;
}



Measured memory_bytes: 3628
def f(s):
    p=0
    for i in str(s):
        p+=int(i)
    return p
N=int(input())
i=1
ans=f(N)
while N>=10**i:
    p=f((N//10**i)*(10**i)-1)
    ans=max(ans,p)
    i+=1
print(ans)  
    
    
    

Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, m, c;
  int b[SIZE], a[SIZE];

  cin >> n >> m >> c;

  for(int i=0;i<m;i++)
    scanf("%d", b+i);

  int ans = 0;

  for(int i=0;i<n;i++) {
    ll sum = 0;
    for(int j=0;j<m;j++) {
      scanf("%d", a+j);
      sum += a[j] * b[j];
    }
    sum += c;
    ans += sum > 0;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int a,b,c,d;

bool f(int x,int y){
	return abs(x-y)<=d;
}

int main(){
	cin>>a>>b>>c>>d;
	if(f(a,c)||f(a,b)&&f(b,c)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int out = a - b * 2;
        if(out <= 0){
            System.out.println("0");
        }else{
            System.out.println(out);
        }
    }
}

Measured memory_bytes: 23764
data =[]
data2 = []
cnt = 0
cnt2 = 0

n,k = gets.chomp.split(" ").map(&:to_i)
data = gets.chomp.split(" ").map(&:to_i)

for i in 0...n do
 for j in (i+1)...n do
   if data[j] < data[i]
     cnt+=1
   end
 end
end

data2 = data+data
l= n*2

for i in 0...n do
 for j in n...l do
   if data2[j] < data2[i]
     cnt2+=1
   end
 end
end

#p cnt                                                                                   
#p cnt2                                                                                  

puts (cnt*k+cnt2*k*(k-1)/2)%1000000007


Measured memory_bytes: 1916