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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }

vector<int> calc_z(const string &s) {
  int n = s.size();
  vector<int> z(n,0);
  int l = 0, r = 0;
  for (int i = 1; i < n; i++) {
    if (i <= r) {
      int k = i-l;
      z[i] = min(z[k], r-i+1);
    }
    while (i+z[i] < n && s[z[i]] == s[i+z[i]]) z[i]++;
    if (i+z[i]-1 > r) {
      l = i; r = i+z[i]-1;
    }
  }
  return z;
}

const int INF = 1000000000;
const int MAX_N = 500000;
string s,t;
int n,m;
bool vis[MAX_N];
int ans[MAX_N];
vi z;
bool match[MAX_N];

int rec(int i, int s) {
  if (ans[i] >= 0) return ans[i];

  if (vis[i]) return ans[i] = INF;
  vis[i] = true;

  if (!match[i]) return ans[i] = 0;

  return ans[i] = min(rec((i+m)%n,s)+1,INF);
}

int main()
{
  cin >> s >> t;
  n = s.size();
  m = t.size();

  fill_n(ans,n,-1);

  string s_ = s;
  forn(i,m) {
    s_.push_back(s[i%n]);
  }

  z = calc_z(t+s_);
  forn(i,n) {
    match[i] = z[m+i] >= m;
  }

  int res = 0;
  for (int i = 0; i < n; i++) {
    chmax(res,rec(i,i));
  }

  cout << (res==INF?-1:res) << endl;

  return 0;
}


Measured memory_bytes: 18892
#include <cstdio>
#include <algorithm>

int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 55;
int x[maxn], y[maxn];
int fa[maxn];

inline int find(int u) {
	if(fa[u] == u) return u;
	return fa[u] = find(fa[u]);
}

int calc(int p, int q, int n)
{
	for(int i = 1; i <= n; i ++)
		fa[i] = i;
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= n; j ++)
			if(x[j] - x[i] == p and y[j] - y[i] == q)
				fa[find(i)] = find(j);
	int res = 0;
	for(int i = 1; i <= n; i ++)
		if(fa[i] == i)
			res ++;
	return res;
}

int main()
{
	int n = read();
	for(int i = 1; i <= n; i ++) {
		x[i] = read();
		y[i] = read();
	}
	int ans = 1000000000;
	for(int i = 1; i <= n; i ++)
		for(int j = 1; j <= n; j ++)
			ans = std::min(ans, calc(x[j] - x[i], y[j] - y[i], n));
	printf("%d\n", ans);
}


Measured memory_bytes: 128
import sys
try:sys.stdin,sys.stdout=open('in.txt','r'),open('out.txt','w')
except:pass
ii1=lambda:int(sys.stdin.readline().strip()) # for interger
is1=lambda:sys.stdin.readline().strip() # for str
iia=lambda:list(map(int,sys.stdin.readline().strip().split())) # for List[int]
isa=lambda:sys.stdin.readline().strip().split() # for List[str]
mod=int(1e9 + 7);from collections import *;from math import *

###################### Start Here ######################

def fun(graph,root):
    visited[root]=True
    queue = deque()
    queue.append(root)
    while len(queue)>0:
        temp = queue[0]
        queue.popleft()
        # print(temp,end=' ')
        for i in range(0,len(graph[temp])):
            if  visited[graph[temp][i]]== False:
                visited[graph[temp][i]] = True
                queue.append(graph[temp][i])
n,m = iia()
graph = [[] for ii in range(n)]
# print(graph)
visited = [False]*(n)
for i in range(m):
    a,b = iia()
    a-=1
    b-=1
    graph[a].append(b)
    graph[b].append(a)
ans=0
# print(graph)
for i in range(n):
    if visited[i]==False:
        fun(graph,i)
        ans+=1
        # print(ans)
# print(ans)
if ans==1:
    print(0)
else:
    print(ans-1)
# print(visited)


Measured memory_bytes: 86928
#include <iostream>
#include <cstring>

using namespace std;

const int Z = 1e9+7;

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

    int dp[n+1][n+1][n*n+1];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            for (int k = 2 * j - 2; k <= n * n; k++) {
                if (k >= 2 * j) {
                    dp[i][j][k] = 1ll * (2 * j + 1) * dp[i-1][j][k-2*j] % Z;
                }
                if (j <= i - 1 && k >= 2 * j + 2) {
                    dp[i][j][k] = (dp[i][j][k] + 1ll * (j + 1) * (j + 1) * dp[i-1][j+1][k-2*j-2]) % Z;
                }
                if (j >= 1 && k >= 2 * j - 2) {
                    dp[i][j][k] = (dp[i][j][k] + dp[i-1][j-1][k-2*j+2]) % Z;
                }
            }
        }
    }

    cout << dp[n][0][k] << endl;

    return 0;
}


Measured memory_bytes: 25600
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.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
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        x: usize,
    }

    let mut count = 0;
    for i in 0..=a {
        for j in 0..=b {
            if x >= 500 * i + 100 * j {
                let r = x - (500 * i + 100 * j);
                if r % 50 == 0 {
                    let r = r / 50;
                    if r <= c {
                        count += 1;
                    }
                }
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


int main(){
  int n,m;
  cin>>n>>m;
  int interval[n+2]={};
  int l,r;
  REP(i,m){
    cin>>l>>r;
    interval[l]++;
    interval[r+1]--;
  }
  REP(i,n+2){
    if(i==0){
      continue;
    }else{
      interval[i] += interval[i-1];
    }
  }
  int ans=0;
  REPP(i,n){
    if(interval[i]==m){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
N=int(input())
a=N//27
b=N%27
s=''
if N<27:
  print(chr(N+96))
else:
  n=N
  j=0
  for i in range(1,11):
    if n-1-pow(26,i)>=0:
      n-=pow(26,i)
      j=i
    else:
      break
  for k in range(j,-1,-1):
    if k==0:
      s=s+chr(n-1+97)
    else:
      s=s+chr((n-1)//pow(26,k)+97)
      n-=((n-1)//pow(26,k))*pow(26,k)
  print(s)

Measured memory_bytes: 8904
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(void)
{
  char genbun[101]={'\0'};

  while(scanf("%s",genbun)!=EOF){
    int i,j,n;

    for(i=0;genbun[i]!='\0';i++){
      if(genbun[i]!='@')
	printf("%c",genbun[i]);
      else{
	n=genbun[i+1]-'0';
	for(j=0;j<n;j++)
	  printf("%c",genbun[i+2]);
	i+=2;
      }
    }
      putchar('\n');
  }

  return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

int p[200000];
long long pairwise_nums(long long n, long long d){
    if(d == 0){
        return n;
    }
    if(n > 2 * d){
        return 2 * d + (n - 2 * d) * 2;
    } else {
        return 2 * (n - d);
    }
}
int main(){
    long long n;
    long long m;
    long long d;
    cin >> n >> m >> d;
    double pairwise_exp = (double) pairwise_nums(n, d) / (double) (n * n) * (m - 1);
    printf("%.10f\n", pairwise_exp);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

odd = 0
single_even = 0
double_even = 0
for a in A:
  if a%2:
    odd += 1
  elif a%2==0 and a%4:
    single_even +=1
  else:
    double_even += 1
    
if (odd == double_even +1 and single_even%2==0) or (odd <= double_even):
  print('Yes')
else:
  print('No')
  
    

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

  int N , M , O , P ;
  cin >> N >> M >> O >> P ;
  int ans = 0 ;
    rep(j,3001){
      rep(k,3001){
        if( ( P - j*M - O*k ) % N ==  0 && ( P - j*M - O*k ) >= 0 ) ans++ ;
      }
    }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define REM 1000000007
typedef long long ll;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  for(int i=0;i<m;i++) cin>>a[i];

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

  int k=0;
  vector<ll> dp(n+1);
  dp[0]=1;
  if(m!=0 && a[k]==1){
    dp[1]=0;
    k++;
  }else{
    dp[1]=1;
  }
  for(int i=2;i<=n;i++){
    if(m!=0 && i==a[k]){
      dp[i]=0;
      if(k<m-1) k++;
    }else{
      dp[i]=dp[i-1]+dp[i-2];
      dp[i]%=REM;
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 1408
h, w = list(map(int, input().split()))
li = []
for _ in range(h):
    li.append(input())

def func():
    for hh in range(h):
        for ww in range(w):
            if li[hh][ww] == '.':
                continue
            if ww - 1 >= 0 and li[hh][ww - 1] == '#':
                continue
            if ww + 1 < w and li[hh][ww + 1] == '#':
                continue
            if hh - 1 >= 0 and li[hh - 1][ww] == '#':
                continue
            if hh + 1 < h and li[hh + 1][ww] == '#':
                continue
            return 'No'
    return 'Yes'

print(func())


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,h,w;
    cin>>h>>w;
    
    char a[h+2][w+2];
    for(i=1;i<=h;i++)
    {
        for(j=1;j<=w;j++)
        cin>>a[i][j];
    }

    for(i=0;i<=h+1;i++)
    {
        for(j=0;j<=w+1;j++)
        {
            if(i==0 || i==h+1)
            a[i][j]='#';
            else if(j==0 || j==w+1)
            a[i][j]='#';
        }
    }

    for(i=0;i<=h+1;i++)
    {
        for(j=0;j<=w+1;j++)
        cout<<a[i][j];
        cout<<endl;
    }
    return 0;
}

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

const ll M = 1000000007;
char str[3010];
int n, m, c = 1, sum[3010], s[3010], e[3010];
ll dp[3010][3010], cm[3010][3010], chk[3010][3010];

int get(int s, int e){ return sum[e] - sum[s - 1]; }

ll f(int x, int y){
	if(x > m) return 1;
	if(y < 0 || e[x] - s[x] + 1 < y) return 0;
	if(chk[x][y]) return dp[x][y];
	if(e[x] < s[x + 1]){
		dp[x][y] = cm[e[x] - s[x] + 1][y] * f(x + 1, get(s[x + 1], e[x + 1])) % M;
	}
	else{
		for(int i = max(0, y - (e[x] - s[x + 1] + 1)); i <= min(s[x + 1] - s[x], y); i++){
			dp[x][y] = (dp[x][y] + cm[s[x + 1] - s[x]][i] *
						f(x + 1, y - i + get(e[x] + 1, e[x + 1]))) % M;
		}
	}
	chk[x][y] = 1;
	return dp[x][y];
}

int main(){
	scanf("%d%d%s", &n, &m, str + 1);
	for(int i = 1; i <= n; i++) sum[i] = sum[i - 1] + (str[i] == '1');
	for(int x, y, l = 0; m--; ){
		scanf("%d%d", &x, &y);
		if(y <= l) continue;
		l = y;
		if(s[c - 1] == x) e[c - 1] = y;
		else{
			s[c] = x; e[c] = y;
			c++;
		}
	}
	m = c - 1;
	s[m + 1] = n + 1;
	for(int i = 0; i <= n; i++){
		cm[i][0] = 1;
		for(int j = 1; j <= i; j++) cm[i][j] = (cm[i - 1][j - 1] + cm[i - 1][j]) % M;
	}
	printf("%lld\n", f(1, get(s[1], e[1])));
}

Measured memory_bytes: 131840
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 5e5 + 9, M = 1e6 + 9, OO = 1e9 + 7, MOD = 1e9 + 7, MOD2 = 998244353;
const ll INF = 2e18;
using namespace std;

int main() {
	fastIO;
#ifdef LOCAL
//	freopen("input.in", "rt", stdin);
#endif
	ll sum = 0;
	int cnt;
	cin >> cnt;
	for (int i = 1;i <= cnt; ++i) {
		if(i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
	}
	cout << sum;
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;

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

    int a;
    cin >> a;

    cout << a + (a * a) + (a * a * a) << "\n";

    return 0;
}

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

int main() {
  std::string S, T;
  std::cin >> S;
  std::cin >> T;

  if (S.size() + 1 != T.size()) {
    std::cout << "No" << std::endl;
  }

  if (T.substr(0, S.size()) == S) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3632
# coding: utf-8
import sys

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

S = sr()

def check(s):
    return s == s[::-1]

bl = True
if not check(S):
    bl = False
mid = (len(S)-1) // 2
if not check(S[:mid]):
    bl = False
if not check(S[mid+1:]):
    bl = False

print('Yes' if bl else 'No')


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
bool check(const int N, const vector<int> A, const vector<int> F, const int M, const int K) {
  int k = K;
  REP(i,N) {
    k -= max<int>(0, A[i] - M / F[i]);
  }
  return k >= 0;
}
signed main() {
  int N, K; cin >> N >> K;
  vector<int> A(N), F(N);
  REP(i,N) {
    cin >> A[i];
  }
  REP(i,N) {
    cin >> F[i];
  }
  sort(A.begin(), A.end());
  sort(F.rbegin(), F.rend());
  int lb = -1, ub = (int)1e13;
  while(ub - lb > 1) {
    int mid = (ub + lb) / 2;
    (check(N, A, F, mid, K) ? ub : lb) = mid;
  }
  cout << ub << endl;
}


Measured memory_bytes: 8544
import std.algorithm;
import std.stdio;
import std.string;
import std.conv;

void main()
{
    uint[] arr;
    foreach(i; 0 .. 10)
        arr ~= readln().chomp().to!uint();

    arr.sort!"a > b"();
    foreach(i; 0 .. 3)
        writeln(arr[i]);
}

Measured memory_bytes: 1056
#include <bits/stdc++.h>
using namespace std;
#define maxN 200005
#define int long long
int H[maxN],f[maxN],n,A[maxN],Res;
void Update(int t,int x)
{
    while (x<=2e5)
    {
        f[x]=max(f[x],t);
        x+=(x&-x);
    }
}
int Get(int x)
{
    int s=0;
    while (x>=1)
    {
        s=max(f[x],s);
        x-=(x&-x);
    }
    return s;
}
signed main()
{
    //freopen("Q-Flower.inp","r",stdin);
    //freopen("Q-Flower.out","w",stdout);
    cin>>n;
    for (int i=1;i<=n;i++) cin>>H[i];
    for (int i=1;i<=n;i++) cin>>A[i];
    for (int i=1;i<=n;i++)
    {
        Update(Get(H[i]-1)+A[i],H[i]);
        Res=max(Res,Get(H[i]));
    }
    cout<<Res;
}




Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;

int n;
ll a[maxn],b[maxn];

void sort(ll *a,ll md)
{
    int pos=n;
    for(int i=0;i<n;i++)
    {
        if(pos==n&&a[i]>=md)pos=i;
        a[i]=a[i]&(md-1);
    }
    inplace_merge(a,a+pos,a+n);
}

bool solve(ll limit)
{
    ll ans=0;
    int that=n-1;
    for(int i=0;i<n;i++){
        while(that>=0&&a[i]+b[that]>=limit)that--;
        ans+=n-1-that;
    }
    return ans&1;
}

int main()
{
    while (scanf("%d",&n)!=EOF) {
        for(int i=0;i<n;i++)
            scanf("%lld",a+i);
        for(int i=0;i<n;i++)
            scanf("%lld",b+i);
        sort(a,a+n);sort(b,b+n);
        ll ans=0;
        for(int i=61;i>=0;i--)
        {
            sort(a,(ll)2<<i);
            sort(b,(ll)2<<i);
            ll res=solve((ll)1<<i);
            res^=solve((ll)2<<i);
            res^=solve((ll)3<<i);
            ans|=res<<i;
        }
        printf("%lld\n",ans);
    }
}



Measured memory_bytes: 4212
// Problem : 
// 			C - String Transformation
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Beginner Contest 110
// URL : https://atcoder.jp/contests/abc110/tasks/abc110_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s, t;
	cin >> s >> t;
	map<char, char> mp1, mp2;
	for(int i =0 ; i<s.size(); i++){
		if(mp1.count(s[i]) && mp1[s[i]] != t[i]){
			cout << "No";
			return 0;
		}
		if(mp2.count(t[i]) && mp2[t[i]] != s[i]){
			cout << "No";
			return 0;
		}
		mp1[s[i]] = t[i];
		mp2[t[i]] = s[i];
	}
	cout << "Yes";
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    int A,B,C,X;
    cin>>A>>B>>C>>X;
    
    int cnt=0;
    for(int a=0;a<=A;++a)
    for(int b=0;b<=B;++b)
    for(int c=0;c<=C;++c)
    if(500*a+100*b+50*c==X)++cnt;
    
    cout<<cnt<<endl;
}


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

#define sz(x) (int)(x.size())
#define int long long

const int N = 1e5 + 2, inf = 1e18;

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

    int n, m, c, ans = 0;
    cin >> n >> m >> c;
    int b[m];
    for(int i = 0; i < m; i++)
        cin >> b[i];
    for(int i = 0; i < n; i++){
        int val = c;
        for(int j = 0, u; j < m; j++){
            cin >> u;
            val += b[j] * u;
        }
        ans += val > 0;
    }
    cout << ans;
}


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

using namespace std;

class Dice {
public:
	int top, face[6];
	void East() {
		top = face[0];
		face[0] = face[3];
		face[3] = face[5];
		face[5] = face[2];
		face[2] = top;
	}
	void West() {
		top = face[0];
		face[0] = face[2];
		face[2] = face[5];
		face[5] = face[3];
		face[3] = top;
	}
	void North() {
		top = face[0];
		face[0] = face[1];
		face[1] = face[5];
		face[5] = face[4];
		face[4] = top;
	}
	void South() {
		top = face[0];
		face[0] = face[4];
		face[4] = face[5];
		face[5] = face[1];
		face[1] = top;
	}
};

int main() {
	int i;
	string o;
	Dice dice;
	for (i = 0; i<6; i++)
		cin >> dice.face[i];
	cin >> o;
	for (i = 0; i < o.length();i++){
		switch (o[i]) {
		case 'E':
			dice.East();
			break;
		case 'W':
			dice.West();
			break;
		case 'N':
			dice.North();
			break;
		case 'S':
			dice.South();
			break;
		}
	}
	cout << dice.face[0] << endl;
}

Measured memory_bytes: 1204
/* 
  ╔╗         ╔╗              ╔═══╗                                  
  ║║        ╔╝╚╗             ║╔═╗║                                  
  ║║╔╗╔╗╔══╗╚╗╔╝    ╔══╗     ║╚═╝║╔═╗╔══╗╔══╗╔═╗╔══╗ ╔╗╔╗╔╗╔╗╔══╗╔═╗
╔╗║║║║║║║══╣ ║║     ╚ ╗║     ║╔══╝║╔╝║╔╗║║╔╗║║╔╝╚ ╗║ ║╚╝║║╚╝║║╔╗║║╔╝
║╚╝║║╚╝║╠══║ ║╚╗    ║╚╝╚╗    ║║   ║║ ║╚╝║║╚╝║║║ ║╚╝╚╗║║║║║║║║║║═╣║║ 
╚══╝╚══╝╚══╝ ╚═╝    ╚═══╝    ╚╝   ╚╝ ╚══╝╚═╗║╚╝ ╚═══╝╚╩╩╝╚╩╩╝╚══╝╚╝ 
                                         ╔═╝║                       
                                         ╚══╝                       */


//Header files
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#ifndef ONLINE_JUDGE
#include<Personal/debug.h>
#else
#define debug(x...)
#endif

//Short data-types declaration
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vii;  
typedef vector<vector<long long> >vll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vbb;

//Macros
#define MK make_pair
#define EB emplace_back
#define PB push_back
#define F first
#define S second
#define rep(i,start,end) for(int i=(int)start;i<(int)end;i++)
#define repr(i,start,end) for(int i=(int)start;i>(int)end;i--)
#define all(x) (x).begin(), (x).end()

//Constants
const int mod = 1e9+7;

//Some useful functions
ll binpow(ll num,ll pow);
inline int mul(int a,int b) {return (a*1ll*b)%mod;}
inline int add(int a,int b) {return (a+0ll+b)%mod;}
inline int sub(int a,int b) {return ((a+0ll-b)%mod+mod)%mod; }
/*------------------------------------------------------Code Starts------------------------------------------------------*/
inline void solve()
{
	string s;
	cin>>s;
	int ans=0;
	rep(i,0,s.size())
	{
		if(s[i]=='R')
		{
			int j=i+1;
			while(j<(int)s.size() && s[j]=='R') j++;
			ans=max(ans,j-i);
			i=j-1;
		}
	}
	cout<<ans<<'\n';
}

int main()
{
	auto start = high_resolution_clock::now();
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start); 
	cerr<<duration.count()<<" microseconds\n";
	return 0;
}
/*------------------------------------------------------Code ends------------------------------------------------------*/
ll binpow(ll num,ll pow)
{
	if(pow==0)
		return 1;
	ll val=binpow(num,pow/2);
	val*=val;
	if(pow&1) val*=num;
	return val;
}



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

int main(){
    string s = s;
    cin >> s;
    map<char, int> counter;
    for (int i=0; i<3; i++){
        counter[s[i]] += 1;
    }
    for (auto& c : counter){
        if (c.second > 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3600
MAX_INT = int(10e10)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def combi(a,b):
    C = 1
    for j in range(b):
        C = C*(a-j)//(j+1)
    return C

N,K = IL()

print(N-K+1)

Measured memory_bytes: 3064
a,b,n=map(int,input().split())
i=(n//b)*b
r=(a*n)//b-a*(n//b)
if i>1:
    x=b*(i+1)-1
    r1=(a*x)//b-a*(x//b)
else:
    r1=0
print(max(r,r1))

Measured memory_bytes: 61692
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

vector<pair<int,int> > v[112345];
long long int dist[112345];
long long int INF = 112345678901234;

int N;
int main () {
    cin >> N;
    for(int i=1; i<=N; i++) dist[i] = INF;

    for(int i=0; i<N-1; i++) {
        int a,b,c;
        cin >> a >> b >> c;
        v[a].push_back(make_pair(b,c));
        v[b].push_back(make_pair(a,c));
    }

    int Q,K;
    cin >> Q >> K;

    dist[K] = 0;
    queue<int> que;
    que.push(K);

    while( !que.empty() ) {
        int s = que.front(); que.pop();
        for(int i=0; i<v[s].size(); i++) {

            int g = v[s][i].first;
            if( dist[s] + v[s][i].second < dist[g] ) {
                dist[g] = dist[s] + v[s][i].second;
                que.push(g);
            }
        }
    }

    for(int i=0; i<Q; i++) {
        int x,y;
        cin >> x >> y;
        cout << dist[x] + dist[y] << endl;
    }
    return 0;
}


Measured memory_bytes: 9076
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>


int max(int a, int b){
    if(a > b){
        return a;
    }else{
        return b;
    }
}

int main(){
    char S[4];
    scanf("%s", &S);

    int cnt = 0;
    int i;
    for(i=0; i<4; i++){
        if(S[i] == '+'){
            cnt++;
        }else{
            cnt--;
        }
    }    

    printf("%d\n", cnt);

    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    int A, B, H, M;
    cin >>A>> B>> H>> M;
    const double PI=3.14159265358979323846;
    double angle=1.0/6.0*PI*(H-11.0/60.0*M);
    double r=sqrt(A*A+B*B-2.0*A*B*cos(abs(angle)));
    cout << fixed <<setprecision(20) << r << endl;
    return 0;

}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pi acos(-1.0)
int main()
{
    int c,i,j,t,n,a,b,f;
    cin>>t;
    cin>>a>>b;
    for(i=a;i<=b;i++)
    {
        if(i%t==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
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 (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

const ll INF = (1ll<<60);
ll dp[2020][2020];

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    priority_queue<pll> pq;
    REP(i, N){
        pq.push({A[i], i});
    }

    REP(i, 2020)REP(j, 2020) dp[i][j] = -INF;
    dp[0][0] = 0;
    REP(i, N){
        auto tmp = pq.top();pq.pop();
        ll val = tmp.first;
        ll pos = tmp.second;
        REP(j, N){
            if(dp[i][j] == -INF) continue;
            chmax(dp[i+1][j+1], dp[i][j]+val*abs(pos-j));
            chmax(dp[i+1][j], dp[i][j]+val*abs((N-1-(i-j)) - pos));
        }
    }

    ll ma = 0;
    REP(i, N+1) chmax(ma, dp[N][i]);
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 35620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple

	
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int a,b,h; cin>>a>>b>>h;
	cout<<( h/2 * (a+b) );
	
	return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define Graph vector<vector<int>>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long N, long long M, std::vector<long long> H,
          std::vector<long long> A, std::vector<long long> B) {}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> H(N);
    for (ll i = 0; i < N; i++) {
        cin >> H.at(i);
    }
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for (int i = 0; i < M; i++) {
        cin >> A.at(i) >> B.at(i);
    }

    for (ll i = 0; i < M; i++) {
        A.at(i)--;
    }

    for (ll i = 0; i < M; i++) {
        B.at(i)--;
    }

    vll goodtenbou(N);

    for (ll i = 0; i < N; i++) {
        goodtenbou.at(i) = 0;
    }

    for (ll i = 0; i < M; i++) {
        if (H.at(A.at(i)) > H.at(B.at(i))) {
            goodtenbou.at(B.at(i)) = 1;
        }

        else if (H.at(A.at(i)) < H.at(B.at(i))) {
            goodtenbou.at(A.at(i)) = 1;
        }

        else {
            goodtenbou.at(A.at(i)) = 1;
            goodtenbou.at(B.at(i)) = 1;
        }
    }

    ll count = 0;

    for (ll i = 0; i < N; i++) {
        if (goodtenbou.at(i) == 0) {
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 6472
n,x,y=map(int,input().split())
ans=[0]*n #0はダミー
for i in range(1,n):
    for j in range(n+1):
        if j<=i:
            continue
        a=j-i
        b=abs(x-i)+1+abs(y-j)
        aa=min(a,b)
        ans[aa]+=1

for i in range(1,n):
    print(ans[i])

Measured memory_bytes: 46684
#include <stdio.h>
#include <string.h>
#define N 2000001

void insert(int);
int ext(void);
void increaseKey(int);
void maxHeapify(int);

int h,A[N],largest;

int main(){
  int a,i;
  char com[10],in[]="insert",end[]="end";

  
  h=0;
  while(1){
    scanf(" %s",com);
    if(strcmp(com,in)==0){
      //if(com[0] == 'i'){
      scanf(" %d",&a);
      insert(a);
    }
    else if(strcmp(com,end)==0){
      break;
    }
    else{
      printf("%d\n",ext());
    }
    //for(i=1;i<5;i++) printf("[%d,%d]",i,A[i]);
  }
  
  return 0;
}

void insert(int a){
  h++;
  A[h] = -1000000;
  increaseKey(a);
}

void increaseKey(int a){
  int i,put;
  /*printf("[3 %d]",a);*/
  i=h;
  if(a < A[i]) return;
  A[i] = a;
  while(i > 1 && A[i / 2] < A[i]){
    put = A[i];
    A[i] = A[i / 2];
    A[i / 2] = put;
    i = i / 2;
  }
}

int ext(void){
  int max,i;
  if(h < 1) return -1000000;
  max = A[1];
  A[1] = A[h--];
  maxHeapify(1);
  return max;
}

void maxHeapify(int i){
  int put;
  
  if(2*i <= h && A[2*i] > A[i]) largest = 2*i;
  else largest = i;
  if(2*i+1 <= h && A[2*i+1] > A[largest]) largest = 2*i+1;

  if(largest != i){
    put = A[i];
    A[i] = A[largest];
    A[largest] = put;
    maxHeapify(largest);
  }
}



Measured memory_bytes: 5604
import math

def main():
  H = float(input())
  cnt = 0
  ans = 1
  
  while H > 1:
    H = math.floor(H / 2)
    #print(H)
    cnt += 1
    ans += 2 ** cnt
  
  #print(int(2 ** cnt))
  print(ans)
  
main()

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    bool ok = true;
    rep(i, N) {
        if (A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) {
            ok = false;
            break;
        }
    }
    if (ok)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;
}

Measured memory_bytes: 3632
W,H,N = map(int,input().split())
a = []
for i in range(N):
    b = list(map(int,input().split()))
    a.append(b)
xs = 0
xe = W
ys = 0
ye = H
for i in range(N):
    if a[i][2] == 1 and xs < a[i][0]:
        xs = a[i][0]
    elif a[i][2] == 2 and xe > a [i][0]:
        xe = a[i][0]
    elif a[i][2] == 3 and ys < a[i][1]:
        ys = a[i][1]
    elif a[i][2] == 4 and ye > a[i][1]:
        ye = a[i][1]
if xs < xe:
    w = xe - xs
else:
    w = 0
if ys < ye:
    h = ye - ys
else:
    h = 0
print(w*h)

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 998244353;
Int INF = 1e18;
double EPS = 0.00000001;

Int f[1001][1001];

int main() {
    Int n;
    cin >> n;
    vector<queue<Int>> a(n + 1);
    for (Int i = 1; i <= n; i++) {
        for (Int j = 0; j < n - 1; j++) {
            Int x;
            cin >> x;
            a[i].push(x);
        }
    }
    queue<pair<Int, Int>> cur, next;
    for (Int i = 1; i <= n; i++) {
        cur.push({i, a[i].front()});
    }
    Int res = 0;
    bool update = true;
    while (update) {
        update = false;
        while (!cur.empty()) {
            pair<Int, Int> p = cur.front();
            if (f[p.fi][p.se] == 0) {
                f[p.fi][p.se] = f[p.se][p.fi] = p.fi;
            }
            else {
                update = true;
                a[p.fi].pop();
                a[f[p.fi][p.se]].pop();
                if (!a[p.fi].empty()) {
                    next.push({p.fi, a[p.fi].front()});
                }
                if (!a[f[p.fi][p.se]].empty()) {
                    next.push({f[p.fi][p.se], a[f[p.fi][p.se]].front()});
                }
            }
            cur.pop();
        }   
        while (!next.empty()) {
            cur.push(next.front());
            next.pop();
        }
        res++;
    }
    bool check = true;
    for (Int i = 1; i <= n; i++) {
        if (!a[i].empty()) {
            check = false;
        }
    }
    dump(check ? res - 1 : -1);
    return 0;
}

Measured memory_bytes: 16768
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int max = 999 * 5 * 19 + 999 * 5 * 20 +  999 / 3 * 5 + 1;
    int y, m, d;
    for(int i = 0; i < n; i++){
        cin >> y >> m >> d;
        y--;
        m--;
        int x;
        x = y * 5 * 19 + y * 5 * 20 + y / 3 * 5;
        if((y+1) % 3 == 0){
            x = x + m*20 + d;
        }
        else{
            x = x + m * 19 + (m + 1) /2 + d;
        }
        cout << max - x << endl;
    }
   return 0;
}



Measured memory_bytes: 3000
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest119-B
#  TODO https://atcoder.jp/contests/abc119/tasks/abc119_b

def solveProblem(personNumber):
	sumPrice = 0.0
	personRange = range(0,personNumber,+1)
	for _ in personRange:
		price,kahei = map(str,input().strip().split(' '))
		if(kahei == "BTC"):
			floatPrice = float(price)
			sumPrice = sumPrice + 380000.0 * floatPrice
		else:
			intPrice = float(price)
			sumPrice = sumPrice + intPrice
	answer = sumPrice
	return answer


if __name__ == '__main__':
	N = int(input().strip())
	solution = solveProblem(N)
	print("{}".format(solution))


Measured memory_bytes: 3060
#include <vector>
#include <iostream>
#include <utility>

using namespace std;

struct edge {
    int src;
    int dst;
    int weight;
};

using graph = vector<vector<edge>>;

pair<int, int> visit(int v, int parent, const graph& G) {
    pair<int, int> r(0, v);
    for (const auto& e : G[v]) {
        if (e.dst == parent) {
            continue;
        }
        auto t = visit(e.dst, v, G);
        t.first += e.weight;
        if (r.first < t.first) {
            r = t;
        }
    }
    return r;
}

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

    graph G(n);
    for (int i = 0; i < n-1; ++i) {
        int s, t, w;
        cin >> s >> t >> w;
        G[s].push_back(edge{s, t, w});
        G[t].push_back(edge{t, s, w});
    }
    auto r = visit(0, -1, G);
    auto t = visit(r.second, -1, G);
    cout << t.first << endl;

    return 0;
}

Measured memory_bytes: 15896
K = int(input())

if K <= 9:
    print(K)
    exit()

ll = [1,2,3,4,5,6,7,8,9]
aft_l = []
cnt = 9
while cnt < K:
    for l in ll:
        tmp = 10 * l
        last = l%10
        if last >= 1:
            aft_l.append(tmp+last-1)
            cnt += 1
            if cnt == K:
                print(aft_l[-1])
                exit()
        
        aft_l.append(tmp+last)
        cnt += 1
        if cnt == K:
            print(aft_l[-1])
            exit()
        if last <= 8:
            aft_l.append(tmp+last+1)
            cnt +=1
            if cnt == K:
                print(aft_l[-1])
                exit()
    ll = aft_l
    aft_l = []


Measured memory_bytes: 6260
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0]*(n+1)
        self.nsize = [1]*(n+1)
    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
        return self.par[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.nsize[y] += self.nsize[x]
        else:
            if x != y:
                self.nsize[x] += self.nsize[y]
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    def length(self, x):
        t = self.find(x)
        return self.nsize[t]
    
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


n, m = map(int,input().split())
uf = UnionFind(n)
N = n*(n-1)//2
ans = [N]
bridge = []
for i in range(m):
    t1, t2 = map(int,input().split())
    bridge.append([t1,t2])
    
for x,y in bridge[::-1]:
    if uf.find(x) != uf.find(y):
        ans.append(N - uf.length(x)*uf.length(y))
        N -= uf.length(x)*uf.length(y)
        uf.union(x,y)
    else:
        ans.append(N)
for i in ans[0:-1][::-1]:
    print(i)

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

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

    int ans = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] != s[s.size() - 1 - i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ALDS1_2_B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            int[] line = ReadIntAr();

            int swapTimes = SelectionSort(line);

            Console.WriteLine(string.Join(" ", line.Select(x => x.ToString()).ToArray()));
            Console.WriteLine(swapTimes);
        }

        //●選択ソート
        public static int SelectionSort(int[] array)
        {

            int swapTimes = 0;

            int min = 0;
            for (int i = 0 ; i < array.Count() ; i++)
            {
                min = i;
                for (int j = i ; j < array.Count() ; j++)
                {
                    if(array[j] < array[min]) min = j;
                }

                if (i != min)
                {
                    int tmp = array[i];
                    array[i] = array[min];
                    array[min] = tmp;
                    swapTimes++;
                }

            }
            return swapTimes;
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 18364
#include<stdio.h>

int main()
{
    int s, x, sum =0;
    int N;
    scanf("%d", &s);
    N=s;
    x = 10;
    while(s>=1)
    {
        sum += s%x;
        s = s/x;
    }

    if(N%sum==0)
        printf("Yes");
    else
        printf("No");


    return 0;
}

Measured memory_bytes: 1724
#include<iostream>
using namespace std;
int main(){
	long long a[10000], n, x, y, z;
	x = 1000000;
	y = -1000000;
	z = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		if (a[i] < x){
			x = a[i];
		}
		if (a[i] > y){
			y = a[i];
		}
				z = z + a[i];

			}


		
	
	cout << x <<" "<< y <<" "<< z << endl;
	return 0;

}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
vector<ii>wq;
int main()
{
    int g,t,z,x,re;
    ll q,lm=0;
    scanf("%d %lld",&t,&q);
    for(g=0;g<t;g++){
        scanf("%d %d",&z,&x);
        wq.push_back(ii(z,x));
    }
    sort(wq.begin(),wq.end());
    for(g=0;g<t;g++){
        lm+=wq[g].second;
        if(lm>=q){
            re=wq[g].first;
            break;
        }
    }
    printf("%d\n",re);
    return 0;
}


Measured memory_bytes: 1400
import Data.List

main = interact $ unlines . map (show' . puzzle . map (read . return)) . lines
 where show' xs = if null xs then "0" else unwords $ map show xs

puzzle tehai = filter is_machi [1..9]
 where
  is_machi n
   | (length $ filter (== n) tehai) >= 4 = False
   | otherwise = is_agari (sort (n:tehai))
  is_agari ns = any of_atama cand_atama
   where
    of_atama n = is_4mentsu (Just (ns \\ [n,n]))
    cand_atama = map head $ filter ((>=2) . length) $ group $ ns
  
  is_4mentsu Nothing = False
  is_4mentsu (Just []) = True
  is_4mentsu (Just ns'@(n1:n2:n3:ns))
   | (n1==n2) && (n2==n3) = is_4mentsu (Just ns) || is_4mentsu (pick_shuntsu ns')
   | otherwise =  is_4mentsu (pick_shuntsu ns')
  
  pick_shuntsu (n:ns)
   | elem (n+1) ns && elem (n+2) ns = Just (ns \\ [n+1,n+2])
   | otherwise = Nothing

Measured memory_bytes: 4136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 3536
h, w = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]
B = [list(map(int, input().split())) for _ in range(h)]
grid = [[0] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        m = abs(A[i][j] - B[i][j])
        grid[i][j] = m

bias_inf = 2000
dp = [[[0 for i in range(-bias_inf,bias_inf)] for j in range(w)] for k in range(h)]
dp[0][0][0 - grid[0][0]] = 1
dp[0][0][0 + grid[0][0]] = 1
for i in range(h):
    for j in range(w):
        for k in range(-bias_inf,bias_inf):
            if i == h-1 and j == w-1:
                break
            if dp[i][j][k]:
                if i != h-1 and j != w-1:
                    dp[i][j+1][k + grid[i][j+1]] = 1
                    dp[i+1][j][k + grid[i+1][j]] = 1
                    dp[i][j+1][k - grid[i][j+1]] = 1
                    dp[i+1][j][k - grid[i+1][j]] = 1
                elif j == w-1:
                    dp[i+1][j][k - grid[i+1][j]] = 1
                    dp[i+1][j][k + grid[i+1][j]] = 1
                else:
                    dp[i][j+1][k - grid[i][j+1]] = 1
                    dp[i][j+1][k + grid[i][j+1]] = 1
ans = bias_inf
for i in range(-bias_inf,bias_inf):
    if dp[-1][-1][i]:
        ans = min(ans, abs(i))
print(ans)

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

signed main(void){
  
  int x,y,a,b,c; cin >> x >> y >> a >> b >> c;
  
  vector<int> p(a),q(b),r(c);
  
  for(int i = 0; i < a; i++){ cin >> p[i];} 
  for(int i = 0; i < b; i++){ cin >> q[i];}
  for(int i = 0; i < c; i++){ cin >> r[i];} 
  
  sort(p.rbegin(),p.rend()); sort(q.rbegin(),q.rend()); sort(r.rbegin(),r.rend());
  vector<int> vec;
  for(int i = 0; i < x; i++){ vec.push_back(p[i]);}
  for(int i = 0; i < y; i++){ vec.push_back(q[i]);}
  for(int i = 0; i < c; i++){ vec.push_back(r[i]);}
  
  int sum = 0;
  sort(vec.rbegin(),vec.rend());
  for(int i = 0; i < x+y; i++){ 
    sum += vec[i];
  }
  
  cout << sum << endl;
  
  return 0;
} 
  

Measured memory_bytes: 8432
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toInt() }

    val boss = IntArray(n) {0}

    aa.forEach {
        boss[it-1]++
    }

    boss.forEach {
        println(it)
    }
}

Measured memory_bytes: 70164
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

using namespace std;

int main()
{
    fast;
    ll  n,k;
    cin>>n>>k;
    vector<ll> arr(n);
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    vector<bool> dp(k+1);  /// dp[i] is true  if the first player wins if there are i stones remaining
    /// first  player is nothing but the player who is currently removing stones
    /// dp[i] is true if the opponent looses in remaining stones
    for( ll stones =0;stones<=k; ++stones)
    {
        for(int j=0;j<n;j++)
        {
            if( stones >= arr[j] && !dp[stones-arr[j]] )
            {
                dp[stones] = true;
            }
        }
    }
    if(dp[k])
    {
        cout<<"First";
    }
    else
    {
        cout<<"Second";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    
    cout<<max(A*C,max(A*D,max(B*C,B*D)))<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
const int md = 1e9+7;
int n, ans[4][4][4][4][2], a;
int main(){
    cin >> n;
    if(n == 3) return puts("61")*0;
    rep(i,4) rep(j,4) rep(k,4) rep(l,4){
        if((i == 0 && j == 2 && k == 1) || (i == 2 && j == 0 && k == 1) || (i == 0 && j == 1 && k == 2) || (i == 0 && j == 2 && l == 1) || (i == 0 && k == 2 && l == 1) || (j == 0 && k == 2 && l == 1) || (j == 2 && k == 0 && l == 1) || (j == 0 && k == 1 && l == 2)) continue;
        ans[i][j][k][l][0] = 1;
    }
    for(int m = 5; m <= n; m++){
        rep(i,4) rep(j,4) rep(k,4) rep(l,4){
            ans[i][j][k][l][m&1] = 0;
            if((i == 0 && j == 2 && l == 1) || (i == 0 && k == 2 && l == 1) || (j == 0 && k == 2 && l == 1) || (j == 2 && k == 0 && l == 1) || (j == 0 && k == 1 && l == 2)) continue;
            rep(o,4) (ans[i][j][k][l][m&1] += ans[o][i][j][k][m&1^1]) %= md;
        }
    }
    rep(i,4) rep(j,4) rep(k,4) rep(l,4) a = (a + ans[i][j][k][l][n&1]) % md;
    printf("%d\n", a);
}

Measured memory_bytes: 256