akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b>>c;
    
  	bool flag=false;
    if(a==5&&b==5&&c==7)
      flag=true;
  	else if(a==5&&b==7&&c==5)
      flag=true;
  	else if(a==7&&b==5&&c==5)
      flag=true;
  
  	if(flag)
      cout<<"YES"<<endl;
  	else
      cout<<"NO"<<endl;

}

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

using namespace std;
static const int INF = 999999;
struct SEdge
{
	int From;
	int To;
	int Cost;
};
int V, E;
vector<SEdge> Edge;

vector<int> par;
vector<int> rank;

void init(int n)
{
	par.clear();
	rank.clear();
	par.resize(n);
	rank.resize(n);
	for(int i = 0; i < n; ++i)
	{
		par[i] = i;
		rank[i] = 0;
	}
}

int find(int x)
{
	if(par[x] == x)
	{
		return(x);
	}
	else
	{
		return(par[x] = find(par[x]));
	}
}

void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	if(x == y)
	{
		return;
	}
	if(rank[x] < rank[y])
	{
		par[x] = y;
	}
	else
	{
		par[y] = x;
		if(rank[x] == rank[y])
		{
			++rank[x];
		}
	}
}

bool same(int x, int y)
{
	return(find(x) == find(y));
}

bool comp(const SEdge& e1, const SEdge& e2)
{
	return(e1.Cost < e2.Cost);
}

int Kruskal()
{
	init(V);
	sort(Edge.begin(), Edge.end(), comp);
	int res = 0;
	for(int i = 0; i < E; ++i)
	{
		SEdge e = Edge[i];
		if(!same(e.From, e.To))
		{
			unite(e.From, e.To);
			res += e.Cost;
		}
	}
	return(res);
}

void solve()
{
	while(cin >> V, V)
	{
		cin >> E;
		Edge.clear();
		Edge.resize(E);
		for(int i = 0; i < E; ++i)
		{
			SEdge e;
			scanf("%d,%d,%d", &e.From, &e.To, &e.Cost);
			e.Cost = e.Cost / 100 - 1;
			Edge[i] = e;
		}
		cout << Kruskal() << endl;
	}
}

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

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

const int maxn = 110000;
const int mod = 1e9 + 7;

ll fac[maxn], finv[maxn], inv[maxn];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < maxn; ++i) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<ll> nums(N);
    for (int i = 0; i < N; ++i) {
        ll A;
        cin >> A;
        nums.at(i) = A;
    }

    COMinit();
    sort(nums.begin(), nums.end());
    // if (nums.at(0) < 0) {
    //     ll firstNum = nums.at(0);
    //     for (int i = 0; i < N; ++i) {
    //         nums.at(i) += firstNum;
    //     }
    // }

    ll ans = 0;
    for (int i = K - 1; i < N; ++i) {
        ans = (ans + COM(i,  K - 1) * nums.at(i)) % mod;
    }

    for (int i = 0; i < N - K + 1; i++) {
        ans = (ans - ((COM(N - i - 1, K - 1) * nums.at(i)) % mod) + mod) % mod;
    }

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

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    int N,M;
    cin >> N >> M;
    
    vector<int> son[100001];
    int num_p[100001]={};
    
    for(int i=0; i<M; i++){
        int x,y;
        cin >> x >> y;
        son[x].push_back(y);
        num_p[y]++;
    }
    
    queue<int> q;
    for(int i=1; i<=N; i++){
        if(num_p[i]==0){
            q.push(i);
        }
    }
    
    int d[100001]={};
    while(!q.empty()){
        int temp=q.front();
        q.pop();
        
        for(int i : son[temp]){
            d[i] = max(d[i],d[temp]+1);
            num_p[i]--;
            if(num_p[i]==0){
                q.push(i);
            }
        }
    }
    
    int ans=0;
    for(int i=1; i<=N; i++){
        ans = max(ans,d[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T> using Graph = vector<vector<T>>;

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (__typeof(a.begin()) x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define endl '\n'

int N, Q;
long a[100005], x;

long query(long x) {
  long s = 0;
  long res = 0;
  int i = 0;
  for (int j = 0; j < N; j++) {
    s += a[j];
    while (s > x) {
      res += (j - i);
      s -= a[i];
      i++;
    }
  }

  while (i < N) {
    res += (N - i);
    i++;
  }

  return res;
}

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

  cin >> N >> Q;
  rep(i, N) cin >> a[i];
  rep(loop, Q) {
    cin >> x;
    cout << query(x) << endl;
  }
  return 0;
}

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

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

  int N; cin >> N;
  int M; cin >> M;

  vector<int> p(M, 0);
  vector<int> S(M, 0);
  for (int i = 0; i < M; i++) {
    cin >> p[i];
    p[i]--;

    string temp; cin >> temp;
    if (temp[0] == 'A') S[i] = 1;
  }

  vector<int> F(N, -1);
  vector<int> AC(N, 0);
  for (int i = 0; i < M; i++) {
    if (S[i] == 1) {
      AC[p[i]] = 1;
      if (F[p[i]] == -1) {
        F[p[i]] = i;
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if (AC[i] == 1) ans++;
  }

  ll wrong = 0;
  for (int i = 0; i < M; i++) {
    if (AC[p[i]] == 1 && S[i] == 0 && i < F[p[i]]) wrong++;
  }

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

Measured memory_bytes: 1792
import glob

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\136\\D'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class D(Common):

    def resolve(self):

        S = self.input_data()
        result = [0 for i in range(len(S))]

        # 左端から、スタート地点がRの人が到達する場所を探す。
        # movingは探索中に右に移動している人の数。スタート地点が奇数番目なら1つ目の要素に、偶数番目なら2つ目の要素に入れる。
        moving = [0, 0]
        for i in range(len(S)-1):
            # 右移動が続く場合、現在の位置の人をmovingに追加。
            if S[i] == 'R' and S[i+1] == 'R':
                if (i + 1) % 2 == 1:
                    moving[0] += 1
                else:
                    moving[1] += 1

            # はさまれる場所が見つかった場合はそこまでに見つかった右移動の人の数をresultに足す。
            if S[i] == 'R' and S[i + 1] == 'L':
                if (i + 1) % 2 == 1:
                    result[i] += moving[0] + 1
                    result[i+1] += moving[1]
                else:
                    result[i] += moving[1]
                    result[i+1] += moving[0] + 1
                # 見つかった右移動の人の数をクリア
                moving = [0, 0]

        # 逆向き。右端から、スタート地点がLの人が到達する場所を探す。
        # movingは探索中に左に移動している人の数。スタート地点が奇数番目なら1つ目の要素に、偶数番目なら2つ目の要素に入れる。
        moving = [0, 0]
        for i in range(len(S)-1, 0, -1):
            # 左移動が続く場合、現在の位置の人をmovingに追加。
            if S[i] == 'L' and S[i-1] == 'L':
                if i % 2 == 1:
                    moving[0] += 1
                else:
                    moving[1] += 1

            # はさまれる場所が見つかった場合はそこまでに見つかった左移動の人の数をresultに足す。
            if S[i] == 'L' and S[i-1] == 'R':
                if i % 2 == 1:
                    result[i] += moving[0] + 1
                    result[i-1] += moving[1]
                else:
                    result[i] += moving[1]
                    result[i-1] += moving[0] + 1
                # 見つかった右移動の人の数をクリア
                moving = [0, 0]

        for i in range(len(S)):

            if i != len(S)-1:
                print(str(result[i]), end=' ')
            else:
                print(str(result[i]), end='')

solver = D(REL_PATH)
solver.exec_resolve()

Measured memory_bytes: 5628
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1)
using namespace std;
int a[200005];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int sum=0;
    for(int i=1;i<=m;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    if(n<sum)printf("-1\n");
    else printf("%d\n",n-sum);
//    int T;
//    scanf("%d",&T);
//    while(T--)
//    {
//        int n;
//        scanf("%d",&n);
//        for(int i=1;i<=n;i++)
//        {
//            scanf("%d",&a[i]);
//        }
//    }
}


Measured memory_bytes: 3864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Comparator;

import static java.util.Arrays.sort;


public class Main {
    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br   = new BufferedReader(isr);
        PrintWriter out     = new PrintWriter(System.out);
        int i = 0;
        String line;
        String[] numList = new String[2];
        try {
            while ((line = br.readLine()) != null) {
                numList = line.split(" ");
                int num0 = Integer.parseInt(numList[0]);
                int num1 = Integer.parseInt(numList[1]);
                int sum = num0 + num1;
                System.out.println((int)Math.log10(sum) + 1);
            }
        } catch (Exception e) {
            System.exit(0);
        }
    }
}

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

int main(){
int N;
  cin>>N;
int x=0;
int t=N;  //Nをそのままfor内に入れてしまうと、for終了後にNの値が改変されてしまうからtに置き換える
  for(int i=0; i<9; i++){
   x+=t%10;
   t/=10; 
  }
  if(N%x==0){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
	val scan = Scanner(System.`in`)
	while (true) {
		val x = scan.nextInt()
		val y = scan.nextInt()
		if (x == 0 && y == 0) break
		println(if (x < y) {"$x $y"} else {"$y $x"})
	}
}


Measured memory_bytes: 36776
h,w=gets.split.map(&:to_i)
ss=[]
h.times do
  ss << gets.chomp.chars
end
m=2
h.times do |hi|
  w.times do |wj|
    next if ss[hi][wj]=="#"
    s=[]
    h.times do |ii|
      s << ss[ii].dup
    end
    q=[[hi,wj]]
    s[hi][wj]=0
    k=1
    while q!=[]
      z=[]
      q.each do |i,j|
        if i>0&&s[i-1][j]=="."
          z << [i-1,j]
          s[i-1][j]=k
        end
        if j>0&&s[i][j-1]=="."
          z << [i,j-1]
          s[i][j-1]=k
        end
        if i<h-1&&s[i+1][j]=="."
          z << [i+1,j]
          s[i+1][j]=k
        end
        if j<w-1&&s[i][j+1]=="."
          z << [i,j+1]
          s[i][j+1]=k
        end
      end
      q=z.dup
      k+=1
    end
    m=k if m<k
  end
end
puts m-2


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int gcd(int n, int m)
{
  if (n < m)
  {
    int tmp = m;
    m = n;
    n = tmp;
  }
  if (m == 0)
  {
    return n;
  }
  return gcd(m, n % m);
}

int main()
{
  int n, k;
  vector<int> a(100000);
  cin >> n >> k;
  REP(i, n)
  {
    cin >> a[i];
  }

  int g = a[0];
  int m = -1;
  REP(i, n)
  {
    g = gcd(g, a[i]);
    m = max(m, a[i]);
  }
  if (k % g == 0 && k <= m)
  {
    cout << "POSSIBLE" << endl;
  }
  else
  {
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 640
S = input()
T = input()

ans = 1000000  # 適当に1001以上を初期値にしておきます

# Tが1文字のときlen(S)回、2文字のときlen(S) - 1回 …… なので、
# len(S) - len(T) + 1 回です
for i in range(len(S) - len(T) + 1):
    score = 0
    U = S[i:i + len(T)]  # Sのi文字目から連続するlen(T)文字を、Uとします
    for j in range(len(T)):
        if U[j] != T[j]:
            score += 1
    ans = min(ans, score)

print(ans)

Measured memory_bytes: 9060
#include <stdio.h>

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 100010
#define MAX_INT 9223372036854775807
#define ARR_MAX 100000000

void debug(char * string, long long int target) {
  printf("%s", string);
  printf("%lld", target);
  printf("%c", '\n');
}

long long A[ARR_MAX];
int main() {
  int n;
  scanf("%d", &n);
  rep(i, n) {
    scanf("%lld", &A[i]);
  }

  int zero = 0;
  rep(i, n) {
    if (A[i] == 0) {
      zero = zero + 1;
    }
  }

  if (zero > 0) {
    // a[i] contains 0
    printf("0\n");
    return 0;
  }

  long long prod = 1;
  rep(i, n) {
    if (A[i] <= 1000000000000000000 / prod) {
      // This condition is equivalent to prod * a[i] <= 10^18
      prod *= A[i];
    } else {
      printf("-1\n");
      return 0;
    }
  }
  printf("%lld\n", prod);
  return 0;
}


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

int main(){
  int a,b,minmum;
  cin>>a>>b;
  if(a>b){
    for(int i=0;i<a;i++){
      cout<<b;
    }
  }
  else {
    for(int i=0;i<b;i++){
      cout<<a;
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int a[n];
    rep(i,n)a[i] = s[i] - 48;

    int ans = 0;

    rep(i,1000){
        int b[4];
        int ii = i;
        rep(j,3){
            b[j] = ii % 10;
            ii /= 10;
        }
        b[3] = -1;
        int now = 0;
        rep(j,n){
            if(a[j] == b[now])now++;
        }
        if(now == 3)ans++;
    }

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


Measured memory_bytes: 384
a,b,c,x,y=map(int,input().split())
AB_sum=min(a+b,c*2)#AB1枚ずつの最小値
ans=0
ans+=min(x,y)*AB_sum
if x<y:
    if b<c*2:
        ans+=b*(y-x)
    else:
        ans+=(c*2)*(y-x)
else:
    if a<c*2:
        ans+=a*(x-y)
    else:
        ans+=(c*2)*(x-y)
print(ans)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
	int h,w;

	while(cin>>h>>w){
		if(h==0&&w==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if((i+j)%2==0)cout<<"#";
				else if((i+j)%2==1)cout<<".";
			}
			cout<<endl;
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

int gcd ( int a, int b )
{
	return (b ? gcd(b, a % b) : a);
}

int lcm ( int a, int b )
{
	return a * b / gcd(a, b);
}
vector<int> createPrime ( int num )
{
	vector<int> vp;
	vector<bool> vb(num+1, true);
	vb[0] = vb[1] = false;
	for (int i = 2; i <= num; ++i) {
		if (!vb[i]) { continue; }
		vp.push_back(i);
		for (int j = i+i; j <= num; j+=i) { vb[j] = false; }
	}
	return vp;
}
int lcm3 ( vector<int> vp, vector<int> vn )
{
	int lcm = 1;
	for (int i = vp.size()-1; i >= 0; --i) {
		int p = vp[i], count = 0;
		for (int j = 0; j < vn.size(); ++j) {
			int n = vn[j], cnt = 0;
			while ((n % p) == 0) {
				n /= p;
				++cnt;
			}
			count = max(count, cnt);
		}
		lcm *= pow((double)p, count);
	}
	return lcm;
}
int main() {
	vector<int> p = createPrime( 1000 );
	int n;
	while ( cin >> n ) {
		vector<int> v( n );
		for ( int i = 0; i < n; ++i ) {
			cin >> v[i];
		}
		cout << lcm3( p, v ) << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B;cin >> A >> B;
  rep(x,10000){
    if(x*2/25 == A && x/10 == B){
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Data.List
import Control.Monad
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- 整数の入力
    [n, l] <- map strToInt . words <$> getLine
    -- 文字列の入力
    cs <- replicateM n getLine
    -- 出力
    putStrLn . concat $ sort cs


Measured memory_bytes: 1404
n = int(input())
w = list(map(int, input().split()))

d = 100
l = 0
r = sum(w)
for i in w:
    l += i
    if r-2*l <= 0:
        d = min(abs(r-2*l), abs(d))
        break
    d = r-2*l

print(d)

Measured memory_bytes: 3060
n,a,b=map(int,input().split())
if a>b:
  ans=0
elif n==1:
  if a!=b:
    ans=0
  else:
    ans=1
else:
  m=(n-1)*a+b
  M=(n-1)*b+a
  ans=M-m+1
print(ans)

Measured memory_bytes: 3060
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{

		Scanner scan = new Scanner(System.in);
		ArrayList<String> suite = new ArrayList<String>();
		ArrayList<String> hikaku = new ArrayList<String>();
		ArrayList<Integer> lb = new ArrayList<Integer>();
		ArrayList<Integer> lf = new ArrayList<Integer>();
		ArrayList<Integer> lr = new ArrayList<Integer>();
		ArrayList<Integer> lv = new ArrayList<Integer>();
		int n =scan.nextInt();
		for(int i=0;i<n;i++){
			int bb = scan.nextInt();
			int ff = scan.nextInt();
			int rr = scan.nextInt();
			int vv = scan.nextInt();
			lb.add(bb);
			lf.add(ff);
			lr.add(rr);
			lv.add(vv);
		}
		int heya = 0;
		int tou1 [] = new int [31];
		int tou2 [] = new int [31];
		int tou3 [] = new int [31];
		int tou4 [] = new int [31];
		for(int i =0;i<31;i++){
			tou1[i] = 0;
			tou2[i] = 0;
			tou3[i] = 0;
			tou4[i] = 0;
		}
		for(int i =0;i<lb.size();i++){
				heya = 0;
				heya += lr.get(i);
				heya += (lf.get(i) * 10 - 10);
//				System.out.println(heya);
				if(lb.get(i) == 1){
					tou1[heya] += lv.get(i);
				}
				if(lb.get(i) == 2){
					tou2[heya] += lv.get(i);
				}
				if(lb.get(i) == 3){
					tou3[heya] += lv.get(i);
				}
				if(lb.get(i) == 4){
					tou4[heya] += lv.get(i);
				}
		}
		for(int i = 1;i<31;i++){
			System.out.print(" "+tou1[i]);
			if(i == 10 || i == 20 || i == 30){
				System.out.println("");
			}
//			else{
//				System.out.print(" ");
//			}
		}
		System.out.println("####################");
		for(int i = 1;i<31;i++){
			System.out.print(" "+tou2[i]);
			if(i == 10 || i == 20 || i == 30){
				System.out.println("");
			}
//			else{
//				System.out.print(" ");
//			}
		}
		System.out.println("####################");
		for(int i = 1;i<31;i++){
			System.out.print(" "+tou3[i]);
			if(i == 10 || i == 20 || i == 30){
				System.out.println("");
			}
//			else{
//				System.out.print(" ");
//			}
		}
		System.out.println("####################");
		for(int i = 1;i<31;i++){
			System.out.print(" "+tou4[i]);
			if(i == 10 || i == 20 || i == 30){
				System.out.println("");
			}
//			else{
//				System.out.print(" ");
//			}
		}
	}
}

Measured memory_bytes: 29776
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b, c ] <- sort <$> readInts
	print $ 10 * c + a + b

Measured memory_bytes: 380
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    int k;
    string s;
    cin >> k >> s;

    if(sz(s) <= k){
	P(s);
    }else{
	cout << s.substr(0,k) << "..." << endl;
    }
    return  0;
}


Measured memory_bytes: 3604
//見にくいソースでごめんなさい

#include <stdio.h>

int main(void){
	int a,b,c,count=3;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b){
		count--;
	}
	if(a==c){
		count--;
	}
	if (b==c){
		count--;
	}
	if(count==0) printf("%d\n",1);
	else printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int C = Integer.parseInt(tokens[2]);
		if (A == B) {
			System.out.println(C);
		} else if (A == C) {
			System.out.println(B);
		} else {
			System.out.println(A);
		}
	}

	void calc() {
	}

	void showResult() {
	}
}

Measured memory_bytes: 21204
#include<stdio.h>

int main()
{
    int m;
    char n[5];

    for(m=0; m<3; m++)
    {
        scanf("%c",&n[m]);
        if(n[m]=='7')
            goto end;
    }
    printf("No\n");
    goto finish;
end:
    printf("Yes\n");
finish:
    return 0;
}


Measured memory_bytes: 1596
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FORR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (e), i ## __begin = (b); i -- > i ## __begin;)
#define rep(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define ALL(x) begin (x), end (x)
using namespace std;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  int a;
  string s;
  cin >> a >> s;
  cout << (a < 3200 ? "red" : s) << endl;
}


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

int main() {
  string a, b;
  cin >> a >> b;
  string s = a + b;
  int n = stoi(s);
  bool ans = false;
  for (int i = 0; i * i <= n; ++i) {
    if (i * i == n) {
      ans = true;
      break;
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
long long var(long long a){
    if(a>0) return a;
    return -a;
}
int main() {
    int n,k;
    cin>>n>>k;
    vector<long long> a(n);
    rep(i,n) cin>>a.at(i);
    vector<long long> dp(n);
    dp.at(0)=0;
    dp.at(1)=var(a.at(1)-a.at(0));
    rep(i,n-2){
        vector<long long> cost(min(k,i+2));
        rep(j,min(k,i+2)) cost.at(j)=dp.at(i+1-j)+var(a.at(i+2)-a.at(i+1-j));
        sort(cost.begin(),cost.end());
        dp.at(i+2)=cost.at(0);
    }
    cout<<dp.at(n-1);
}

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

int main(){
    bool n1=false,n2=false,n3=false,n4=false;
    for(int i=0;i<4;i++){
        int n;
        cin>>n;
        if(n==1) n1=true;
        else if(n==7) n2=true;
        else if(n==9) n3=true;
        else if(n==4) n4=true;
    }
    if(n1&&n2&&n3&&n4) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

ans = 0

for _ in range(max(h)):
    if h[0]:
        ans += 1
    for i in range(n - 1):
        if not h[i] and h[i + 1]:
            ans += 1
    for j in range(n):
        if h[j]: h[j] -= 1
print(ans)

Measured memory_bytes: 9100
#include <iostream>
#include <set>

using namespace std;

bool isGroup01(int n) {
    if (n == 1 || n == 3 || n == 5 || n == 7 || n == 8 || n == 10 || n == 12) {
        return true;
    }
    return false;
}

bool isGroup02(int n) {
    if (n == 4 || n == 6 || n == 9 || n == 11) {
        return true;
    }
    return false;
}

bool isGroup03(int n) {
    if (n == 2) {
        return true;
    }
    return false;
}

string f(int x, int y) {


    if (isGroup01(x) && isGroup01(y)) {
        return "Yes";
    }
    if (isGroup02(x) && isGroup02(y)) {
        return "Yes";
    }
    if (isGroup03(x) && isGroup03(y)) {
        return "Yes";
    }

    return "No";
}

int main() {

    int x, y;
    cin >> x >> y;

    string result = f(x, y);
    cout << result << endl;

    return 0;
}


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

using namespace std;

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

  vector<int> abc(3); for (auto& v : abc) cin>>v;
  sort(abc.begin(), abc.end());
  if ((abc[0] == abc[1] and abc[1] != abc[2]) or
      (abc[2] == abc[1] and abc[1] != abc[0])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import math

A,B,X = map(int, input().split())


if X == A*A*B:
    print(0.0)
    exit()

# 半分まで
if A*A*B/2 >= X:

    # X / A = B * ha / 2
    ha = 2.0*X / (A*B) 
    rad = math.atan(B/ha)
    ans = rad * 180.0 / math.pi
# 半分より多い
else:
    ue = 2.0 * X / A / A - B
    ha = 2.0 * (X / A - A*ue) / (B - ue)
    rad = math.atan((B-ue)/ha)
    ans = rad * 180.0 / math.pi

print(ans)

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

int main()
{
    int D; cin >> D;
    int c[27];
    for(int i=1; i<27; i++) cin >> c[i];
    int s[D+1][27];
    for(int i=1; i<=D; i++){
        for(int j=1; j<27; j++) cin >> s[i][j];
    }
    int t[D+1];
    for(int i=1; i<=D; i++) cin >> t[i];
    int last[D+1][27];
    for(int i=1; i<=D; i++){
        for(int j=1; j<27; j++) last[i][j] = 0;
    }

    long long int sat = 0;
    
    for(int d=1; d<=D; d++){
        
        //得られる満足度
        sat += s[d][t[d]];
        for(int dd = d; dd<=D; dd++)
            last[dd][t[d]] = d;
        //失われる満足度
        for(int i=1; i<=26; i++){
            sat -= c[i]*(d-last[d][i]);
        }
        cout << sat << endl;
    }

    return 0;






}

Measured memory_bytes: 3676
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;
#pragma endregion

void solve() {
    int n, w;
    cin >> n >> w;
    vector<pair<ll, ll>> ob(n+1);
    for (int i=1; i<=n; i++) {
        cin >> ob.at(i).first >> ob.at(i).second;
    }
    vector<vector<ll>> dp(n+1, vector<ll>(w+1));
    for (int i=1; i<=n; i++) {
        for (int j=0; j<=w; j++) {
            if (ob.at(i).first <= j) {
                dp.at(i).at(j) = max(dp.at(i-1).at(j), dp.at(i-1).at(j-ob.at(i).first) + ob.at(i).second);
            } else {
                dp.at(i).at(j) = dp.at(i-1).at(j);
            }
        }
    }
    cout << dp.at(n).at(w) << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 80256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int a = vs[0];
			int b = vs[1];
			int k = vs[2];
			for (int i = a; i <= b; i++) {
				if (i < a + k || b - k < i) {
					Console.WriteLine(i);
				}
			}

		}
	}
}


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

using namespace std;

const int N = 100001;
int h[N], dp[N], n;

int solve(int i) {
    if (i == 1) {
        return 0;
    }
    int& ans = dp[i];
    if (ans != -1) {
        return ans;
    }
    ans = 1e9;
    if (i > 1) {
        ans = solve(i - 1) + abs(h[i] - h[i - 1]);
    }
    if (i > 2) {
        ans = min(ans, solve(i - 2) + abs(h[i] - h[i - 2]));
    }
    return ans;
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    memset(dp, -1, sizeof dp);
    cout << solve(n);
    return 0;
}


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

int main(){
    int n,m,i;
    cin>>n>>m;
    vector<pair<long long int,long long int>> li(n);
    for(i=0;i<n;i++){
        cin>>li[i].first>>li[i].second;
    }
    sort(li.begin(),li.end());
    long long int ans = 0,mazai=0;
    for(i=0;mazai<m;i++){
        ans += li[i].first * li[i].second;
        mazai += li[i].second;
    }
    if(mazai>m){
        ans -= li[i-1].first*(mazai-m);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
A = np.array(lr())
total = A.sum()
A *= 4 * M
A = A[A>=total]
bl = len(A) >= M
print('Yes' if bl else 'No')


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

int main(){
    int k,s;
    cin>>k>>s;

    int cnt=0;

    rep2(i,0,k){
        rep2(j,0,k){
            if(s-i-j<=k&&s-i-j>=0){
                cnt++;
            }
        }
    }

    cout<<cnt<<endl;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

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

vector<P> factor(ll n) {
  vector<P> ret;
  ll q = n;
  for (ll d = 2; d * d <= n; d++) {
    if (q % d > 0) continue;
    ll cnt = 0;
    while (q % d == 0) {
      cnt++;
      q /= d;
    }
    ret.push_back(make_pair(d, cnt));
  }
  if (q > 1) ret.push_back(make_pair(q, 1));
  return ret;
}

void solve() {
  ll n, p; cin >> n >> p;
  ll ans = 1;

  vector<P> v = factor(p);

  for (int vi = 0; vi < v.size(); vi++) {
    ll x = v[vi].second / n;
    if (x > 0) ans *= mypow(v[vi].first, x);
  }

  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

x=list(map(int,input().split()))

print(x.index(0)+1)

Measured memory_bytes: 61660
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll m; cin >> m;
    ll x; cin >> x;
    vector <vector <ll>> arr;
    vector <ll> costs;
    REP(i, n){
        ll c; cin >> c;
        costs.push_back(c);
        vector <ll> arrr;
        REP(i, m){
            ll a; cin >> a;
            arrr.push_back(a);
        }
        arr.push_back(arrr);
    }
    ll ans = 1e18;
    REP(i, pow(2, n)){
        ll bit = i;
        ll cost = 0;
        vector <ll> know(m, 0);
        REP(j, n){
            if (bit%2 == 1){
                cost += costs[j];
                REP(idx, m){
                    know[idx] += arr[j][idx];
                }
            }
            bit /= 2;
        }
        bool ok = true;
        REP(idx, m){
            if (know[idx] < x){
                ok = false;
                break;
            }
        }
        if (ok){
            ans = min(ans, cost);
        }
    }
    if (ans == 1e18){
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4068
#include <iostream>
#include<cmath>

using namespace std;

int main()
{
    int n,d,i,sum=0;
    long double x,y;
    cin>>n>>d;
    for(i=1;i<=n;i++){
        cin>>x>>y;
        long double dis=pow(x,2)+pow(y,2);
        dis=sqrt(dis);
        if(dis<=d) sum++;
    }
    cout<<sum;
    return 0;
}


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

class Program
{

    public static void Main( )
    {
        // ## this code is referring to  #14783023  by  (atcoder ID) sndyhg. ##

        var input = Console.ReadLine( ).Split( ).Select( long.Parse ).ToArray( );
        var N = input[ 0 ];
        var M = input[ 1 ];
        var K = input[ 2 ];

        var A = Console.ReadLine( ).Split( ).Select( long.Parse ).ToArray( );
        var B = Console.ReadLine( ).Split( ).Select( long.Parse ).ToArray( );

        var a = new long[ N + 1 ];
        for ( int i = 1; i < N + 1; i++ )
        {
            a[ i ] = a[ i - 1 ] + A[ i - 1 ];
        }
        var b = new long[ M + 1 ];
        for ( int i = 1; i <= M; i++ )
        {
            b[ i ] = b[ i - 1 ] + B[ i - 1 ];
        }

        long j = M;
        long answer = 0;
        for ( int i = 0; i <= N; i++ )
        {
            if ( a[ i ] > K )
            {
                break;
            }


            // memo :  j--  until  the Cumulative Sum of B is less than the Remaining K.
            while ( b[ j ] > K - a[ i ] )
            {
                j--;
            }

            // memo :  the number of  selected  B is "j"  ( b[j] contains B[0]~B[j-1] )
            answer = Math.Max( answer, i + j );
        }
        Console.WriteLine( answer );
    }
}





Measured memory_bytes: 73404
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
signed main(void) {
    int i,j;
    int n, m;
    cin >> n >> m;
    string s, t;
    cin >> s;
    cin >> t;
    if(s[0] != t[0]){
        cout << -1 << endl;
        return 0;
    }
    int g = gcd(n,m);
    int l = n * m / g;
    map<int,char> ma;
    rep(i,n){
        ma[1+i*l/n]=s[i];
    }
    rep(i,m){
        char c = ma[1+i*l/m];
        if('a' <= c && c <= 'z' && c != t[i]){
            cout << -1 << endl;
            return 0;
        }
        ma[1+i*l/m] = t[i];
    }
    cout << l << endl;
}


Measured memory_bytes: 10880
import java.util.Scanner;

public class Main {

	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
	
	public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			int a;
			int b;
			int result;
			a = sc.nextInt();
			b = sc.nextInt();
			if (a>b) {
				if(a-1>b) {
					result=a+(a-1);
					}
				else{
					result=a+b;
					}
				}
			else {
				if(b-1>a) {
					result=b+(b-1);
					}
				else{
					result=a+b;
					}
			}
			// 出力

			System.out.println(result);
	}
}

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

int main(){
  int64_t X,K,D;
  cin >> X >> K >> D;
  int64_t quo=X/D;
  int64_t mod=X%D;
  if(abs(quo)>K){
    cout << min(abs(X+D*K),abs(X-D*K)) << endl;
  }else{
    if((quo-K)%2==0){
      cout << abs(mod) << endl;
    }else{
      cout << min(abs(mod+D),abs(mod-D)) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	ll x,y;
	cin >> x >> y;
	if(x%y == 0){
		puts("-1");
	}
	else cout << x << endl;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define PRINT(a)   cout << (a) << endl
#define RALL(v) rbegin(v), rend(v)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

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

vector< int > divisor(int n) {
  vector< int > ret;
  for(int 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);
}

int main(){
  int n;
  cin >> n;
  vi a(n);
  map<int,int> mp;
  REP(i,n){
    cin >> a[i];
    mp[a[i]]++;
  }

  int ans=0;
  REP(i,n){
    vi v = divisor(a[i]);
    bool ok = true;
    for(auto x: v){
//      cout << x << endl;
      if(x == a[i]){
        if(mp[x]>1)ok=false;
      }else{
        if(mp[x]>=1)ok=false;
      }
    }
    if(ok)ans++;
  }

  PRINT(ans);
  
}



Measured memory_bytes: 32648
n, x, m = map(int, input().split())
a = [-1 for _ in range(10 ** 5 + 2)]
memo = [-1 for _ in range(m)]
a[1] = x
for i in range(2, 10 ** 5 + 2):
    a[i] = a[i-1] ** 2 % m
    if memo[a[i]] == -1:
        memo[a[i]] = i
    else:
        one_loop = i - memo[a[i]]
        start_loop = memo[a[i]]
        break


if start_loop >= n:
    print(sum(a[1:n+1]))
else:
    ans = sum(a[1:start_loop])
    loop, res = divmod(n - start_loop + 1, one_loop)
    ans += sum(a[start_loop: start_loop + one_loop]) * loop
    ans += sum(a[start_loop: start_loop + res])   
    print(ans) 
    

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

int main() {
  int64_t X, K, D;
  cin >> X >> K >> D;
  
  int64_t syou, amari;
  syou = X/D;
  int64_t ans=0;
  if(X<0&&syou+K>=0){
    X-=syou*D;
    amari = K+syou;
    if(amari%2==0)ans = -1*X;
    else ans = D+X;
  }
  else if(X<0 && syou + K<0)ans = 0-K*D-X;
  else if(syou <= K){
    X-=syou*D;
    amari = K-syou;
    if(amari%2==0)ans = X;
    else ans = D-X;
  }
  else if(syou > K)ans = X-K*D;
  
  cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  N = N % 10;
  string res;
  if (N == 3){
    res = "bon";
  } else if (N == 0 || N == 1 || N == 6 || N == 8){
    res = "pon";
  } else {
    res = "hon";
  }
  cout << res << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   int a,b,c,d;
   cin >> a >> b >> c >> d;
   int n=a*b;
   int m=c*d;
   int ans=max(n,m);
   cout << ans <<endl;

}

Measured memory_bytes: 3604