akhauriyash/Code-Regression huggingface dataset:
#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() { 
    int n;cin >> n;
    vi div; 
    int k = sqrt(n);
    for(int i = 1;i<=k;i++) if(n%i==0)div.pb(i);
    cout << keta(n/div[div.size()-1]) << endl;
    return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>

#define INF INT_MAX>>1

using namespace std;

int main(void){
	while(1){
		int n, m, c, s, g; 
		cin >> n >> m >> c >> s >> g;
		if(!n && !m && !c && !s && !g) break;
		s--; g--;

		static int dist[100][100][20];
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				for(int k=0; k<c; k++){
					if(i==j) dist[i][j][k] = 0;
					else dist[i][j][k] = INF;
				}
			}
		}
		for(int i=0; i<m; i++){
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			x--; y--; c--;
			dist[x][y][c] = dist[y][x][c] = min(dist[x][y][c], d);
		}

		int p[20];//int len[20];
		for(int i=0; i<c; i++) {
			cin >> p[i];// scanf("%d",len+i);
		}
		vector< pair<int, int> > poly[20];
		for(int i=0; i<c; i++){
			poly[i].assign(p[i]+1, make_pair(0, 1));
			for(int j=0; j<p[i]-1; j++){
				int q; cin >> q;
				poly[i][j+1].first = q;
			}
			for(int j=0; j<p[i]; j++){
				int r; cin >> r;
				poly[i][j+1].second = r;
			}
			poly[i].back().first=INF;//????
		}

		for(int l=0; l<c; l++){
			//ワーシャルフロイド
			for(int k=0; k<n; k++) for(int i=0; i<n; i++) for(int j=0; j<n; j++){
				dist[i][j][l] = min(dist[i][j][l], dist[i][k][l]+dist[k][j][l]);
			}

		}

		static int cost[100][100][20];
		for(int l=0; l<c; l++){
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					int d = dist[i][j][l];
					if(d == INF){
						cost[i][j][l] = INF;//????
						continue;
					}
					int tmp=0;
					for(int k=0; k<poly[l].size()-1; k++){
						tmp += poly[l][k+1].second*max(min(poly[l][k+1].first, d)-poly[l][k].first, 0);
					}
					cost[i][j][l] = tmp;
				}
			}
		}

		int ans[100][100];
		fill(ans[0], ans[100], INF);
		for(int i=0; i<n; i++) for(int j=0; j<n; j++) for(int k=0; k<c; k++) ans[i][j] = min(ans[i][j], cost[i][j][k]);
		for(int k=0; k<n; k++) for(int i=0; i<n; i++) for(int j=0; j<n; j++) ans[i][j] = min(ans[i][j], ans[i][k]+ans[k][j]);

		if(ans[s][g] != INF) cout << ans[s][g] << endl;
		else cout << -1 << endl;
	}

	return 0;
}


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

int main() {
  ll q,h,s,d;
  cin>>q>>h>>s>>d;
  ll n;
  cin>>n;
  s=min(s,min(4*q,2*h));
  ll ans;
  if(n==1){
    ans=s;
  }else if(n%2==0){
    ans=min(d*(n/2),s*n);
  }else{
    ans=min(d*(n/2)+s,s*n);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[2][2020],x,n=1,ans;
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin>>s;
	for(int i=0;i<=s.size()-1;i++)
	{
		int x=s[i]-'0';
		for(int j=0;j<=2019;j++)
			f[1][(j*10+x)%2019]+=f[0][j];
		f[1][x]++;
		for(int j=0;j<=2019;j++)
		{
			f[0][j]=f[1][j];
			f[1][j]=0;
		}
		ans+=f[0][0];
	}
	cout<<ans;
}


Measured memory_bytes: 3788
#include<stdio.h>
int main()
{
	int x,y,size,nasi=0,max=0,map[14][14]={0};
	for(x=0; x<14; x++)
	{
		for(y=0; y<14; y++)
		{
			if((x==0 || x==1 || x==12 || x==13) || (y==0 || y==1 || y==12 || y==13))
				map[y][x]=-1;
		}
	}
	while(scanf("%d,%d,%d",&x,&y,&size)!=EOF)
	{
		x+=2;
		y+=2;
		if(size==1)
		{
			map[y][x]++;
			if(map[y-1][x]!=-1)
				map[y-1][x]++;
			if(map[y][x-1]!=-1)
				map[y][x-1]++;
			if(map[y][x+1]!=-1)
				map[y][x+1]++;
			if(map[y+1][x]!=-1)
				map[y+1][x]++;
		}
		if(size==2)
		{
			map[y][x]++;
			if(map[y-1][x-1]!=-1)
				map[y-1][x-1]++;
			if(map[y-1][x]!=-1)
				map[y-1][x]++;
			if(map[y-1][x+1]!=-1)
				map[y-1][x+1]++;
			if(map[y][x-1]!=-1)
				map[y][x-1]++;
			if(map[y][x+1]!=-1)
				map[y][x+1]++;
			if(map[y+1][x-1]!=-1)
				map[y+1][x-1]++;
			if(map[y+1][x]!=-1)
				map[y+1][x]++;
			if(map[y+1][x+1]!=-1)
				map[y+1][x+1]++;
		}
		if(size==3)
		{
			map[y][x]++;
			if(map[y-2][x]!=-1)
				map[y-2][x]++;
			if(map[y][x-2]!=-1)
				map[y][x-2]++;
			if(map[y][x+2]!=-1)
				map[y][x+2]++;
			if(map[y+2][x]!=-1)
				map[y+2][x]++;
			if(map[y-1][x-1]!=-1)
				map[y-1][x-1]++;
			if(map[y-1][x]!=-1)
				map[y-1][x]++;
			if(map[y-1][x+1]!=-1)
				map[y-1][x+1]++;
			if(map[y][x-1]!=-1)
				map[y][x-1]++;
			if(map[y][x+1]!=-1)
				map[y][x+1]++;
			if(map[y+1][x-1]!=-1)
				map[y+1][x-1]++;
			if(map[y+1][x]!=-1)
				map[y+1][x]++;
			if(map[y+1][x+1]!=-1)
				map[y+1][x+1]++;
		}
	}
	for(y=0; y<14; y++)
	{
		for(x=0; x<14; x++)
		{
			if(map[y][x]==0)
				nasi++;
			if(max<map[y][x])
				max=map[y][x];
		}
	}
	printf("%d\n%d\n",nasi,max);
	return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int n;
char s[2001];
vector <int> v[2000];

pair<int, pair<int, int>> dfs(int x, int y) {
    int c1 = 0, c2 = 0, c3 = 0, m = 0, sum = 0, i;
    
    for (i = 0; i < v[x].size(); i++) {
        if (v[x][i] == y) continue;
        
        pair<int, pair<int, int>> p = dfs(v[x][i], x);
        
        c1 += p.first;
        c2 += p.second.first;
        c3 += p.second.second;
        m = max(m, p.second.first - p.second.second * 2);
        sum += p.second.first - p.second.second * 2;
    }
    
    c3 += min(sum - m, sum / 2);
    
    if (s[x] == '1') c1++;
    
    c2 += c1;
    
    return make_pair(c1, make_pair(c2, c3));
}

int calc(int x) {
    int sum = 0, m1 = 0, m2 = 0, i;
    
    for (i = 0; i < v[x].size(); i++) {
        pair<int, pair<int, int>> p = dfs(v[x][i], x);
        
        if (p.first > 0) {
            sum += p.second.first;
            if (p.second.first > m1) {
                m1 = p.second.first;
                m2 = p.second.second;
            }
        }
    }
    
    if (sum % 2 == 0 && m1 - m2 * 2 <= sum - m1) {
        return sum / 2;
    } else {
        return 1e9;
    }
}

int main() {
    int ans = 1e9, i;
    
    scanf("%d", &n);
    scanf("%s", s);
    
    for (i = 0; i < n - 1; i++) {
        int a, b;
        
        scanf("%d %d", &a, &b);
        a--;
        b--;
        
        v[a].push_back(b);
        v[b].push_back(a);
    }
    
    for (i = 0; i < n; i++) ans = min(ans, calc(i));
    
    if (ans == 1e9) ans = -1;
    printf("%d\n", ans);
    
    return 0;
}


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

int A[3][3];
bool ok[3][3];

int main(){
  for (int i=0;i<3;++i){
    for (int j=0;j<3;++j){
      cin >> A[i][j];
    }
  }
  int n;
  cin >> n;
  for (int i=0;i<n;++i){
    int b;
    cin >> b;
    for (int j=0;j<3;++j){
      for (int k=0;k<3;++k){
        if(A[j][k] == b) ok[j][k] = true;
      }
    }
  }
  bool bingo = false;
  for (int i=0;i<3;++i){
    int cnt = 0;
    for (int j=0;j<3;++j) if(ok[i][j]) cnt++;
    if (cnt >= 3) bingo = true;
  }
  for (int j=0;j<3;++j){
    int cnt = 0;
    for (int i=0;i<3;++i) if(ok[i][j]) cnt++;
    if (cnt >= 3) bingo = true;
  }
  int cnt = 0;
  for (int i=0;i<3;++i) if(ok[i][i]) cnt++;
  if (cnt >= 3) bingo = true;
  cnt = 0;
  if (ok[0][2] && ok[1][1] && ok[2][0]) bingo = true;

  if (bingo) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int h[] = new int[n];
    
    for(int i = 0 ; i < n ; ++i){
      h[i] = sc.nextInt();
    }
    
    int count = 0;
    int ans = 0;
    
    for(int i = 1 ; i < n ; ++i){
      if(h[i-1]>=h[i]){
        count++;
      }else{
        count = 0;
      }
      
      ans = Math.max(ans,count);

    }
    
    System.out.println(ans);
    
  }
}

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

int main() {
  ll n;
  cin >> n;
  ll ans = n;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ans = min(ans, i + n / i - 2);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.text.ParseException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 変数
        int n = 0; // 参加者
        int x[] = null; // 座標リスト
        int p = 0;
        int energy = 0; // 消費体力

        // 入力値
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        x = new int[n];

        // 座標リスト格納
        for (int i=0; i<n; i++) {
            x[i] = sc.nextInt();
            p += x[i];
        }

        // 集会開催場所算出
        p = (int) Math.round((double)p/n);

        // 体力算出
        for (int i=0; i<n; i++) {
            energy += (x[i]-p) * (x[i]-p);
        }

        // 出力
        System.out.println(energy);
    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}


template<typename Data, typename T>
struct ReRooting{
  struct Node{
    Int to,rev;
    Data data;
    Node(Int to,Int rev,Data data):to(to),rev(rev),data(data){}
  };

  using F1 = function<T(T, T)>;
  using F2 = function<T(T, Data)>;

  vector<vector<Node> > G;
  vector<vector<T> > ld,rd;
  vector<Int> lp,rp;

  const F1 f1;
  const F2 f2;
  const T id;

  ReRooting(Int n,const F1 f1,const F2 f2,const T &id):
    G(n),ld(n),rd(n),lp(n),rp(n),f1(f1),f2(f2),id(id){}

  void add_edge(Int u,Int v,Data d){
    G[u].emplace_back(v,(Int)G[v].size(),d);
    G[v].emplace_back(u,(Int)G[u].size()-1,d);
  }

  // p: idx for edge (not vertex)
  T dfs(Int v,Int p){
    while(lp[v]!=p&&lp[v]<(Int)G[v].size()){
      auto &e=G[v][lp[v]];
      ld[v][lp[v]+1]=f1(ld[v][lp[v]],f2(dfs(e.to,e.rev),e.data));
      lp[v]++;
    }
    while(rp[v]!=p&&rp[v]>=0){
      auto &e=G[v][rp[v]];
      rd[v][rp[v]]=f1(rd[v][rp[v]+1],f2(dfs(e.to,e.rev),e.data));
      rp[v]--;
    }
    if(p<0) return rd[v][0];
    return f1(ld[v][p],rd[v][p+1]);
  }

  vector<T> build(){
    for(Int i=0;i<(Int)G.size();i++){
      ld[i].assign((Int)G[i].size()+1,id);
      rd[i].assign((Int)G[i].size()+1,id);
      lp[i]=0;
      rp[i]=(Int)G[i].size()-1;
    }
    vector<T> res;
    for(Int i=0;i<(Int)G.size();i++){
      res.emplace_back(dfs(i,-1));
    }
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  struct T{
    Int a,b,c;
    T(Int a,Int b,Int c):a(a),b(b),c(c){}
  };

  const Int INF = 1e9;
  auto f1=
    [&](T x,T y){
      vector<Int> vs({x.a,x.b,x.c,y.a,y.b,y.c});
      sort(vs.rbegin(),vs.rend());
      return T(vs[0],vs[1],vs[2]);
    };
  auto f2=
    [&](T x,Int y){
      chmax(x.a,0);
      x.a+=y;
      x.b=-INF;
      x.c=-INF;
      return x;
    };

  Int n;
  cin>>n;
  if(n==1) drop(1);

  ReRooting<Int, T> G(n,f1,f2,T(-INF,-INF,-INF));
  for(Int i=1;i<n;i++){
    Int u,v;
    cin>>u>>v;
    u--;v--;
    G.add_edge(u,v,1);
  }
  auto res=G.build();

  string ans(n+1,'1');

  for(Int i=0;i<n;i++){
    if(G.G[i].size()<3) continue;
    T v=res[i];
    assert(v.a>=v.b);
    assert(v.b>=v.c);
    assert(v.c>=1);
    // cout<<v.a<<" "<<v.b<<" "<<v.c<<endl;
    ans[v.a+min({v.a-1,v.b,v.c})]='0';
  }

  for(Int i=n-1;i>=0;i--)
    if(ans[i+1]=='0') ans[i]='0';

  ans[1]='1';
  ans[2]='1';
  cout<<ans.substr(1)<<endl;
  return 0;
}



Measured memory_bytes: 91180
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define int long long int
#define vec vector<int>
#define mp map<int,int>
#define inf 1e18
using namespace std;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tt=1;
  //cin>>tt;
  while(tt--)
  {
    int n,q;
    cin>>n>>q;
    int a[n+1],b[n+1];
    for(int i=1;i<=n;i++)
        a[i]=n,b[i]=n;
    int w=n,h=n,ans=0;
    while(q--)
    {
      int s;
      cin>>s;
      if(s==1)
      {
        int x;
        cin>>x;
        if(x<w)
        {
          for(int i=x;i<w;i++)
                a[i]=h;
          w=x;
        }
        ans+=a[x]-2;
      }
      else
      {
        int x;
        cin>>x;
        if(x<h)
        {
          for(int i=x;i<h;i++)
                b[i]=w;
          h=x;
        }
        ans+=b[x]-2;
      }
    }
    cout<<((n-2)*(n-2)-ans)<<"\n";
  }
}

Measured memory_bytes: 6704
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
int const N=2e5+2,oo=1e9,M=1e6;
ll const OO=1e18;
double const eps=1e-6,PI=acos(-1);
int mod=oo+7;

int n,m,dp[401][401],vis[401][401];
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
string aa[401];
bool valid(int r,int c){
    return r>-1&&r<n&&c>-1&&c<m;
}
pp dfs(int r,int c){
    vis[r][c]=1;
    pp ret={aa[r][c]=='.',aa[r][c]=='#'};
    for(int i=0;i<4;i++){
        int nr=r+dy[i],nc=c+dx[i];
        if(valid(nr,nc)&&aa[nr][nc]!=aa[r][c]&&!vis[nr][nc]){
            pp t=dfs(nr,nc);
            ret.first+=t.first;
            ret.second+=t.second;
        }
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    ll an=0;
    for(int i=0;i<n;i++)cin>>aa[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(vis[i][j])continue;
            pp ret=dfs(i,j);
            an+=ret.first*1LL*ret.second;
        }
    }
    cout<<an<<'\n';
    return 0;
}

Measured memory_bytes: 21120
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

long long N, A[100009], E;

int main() {
	cin >> N; for (int i = N; i >= 0; i--) { cin >> A[i]; E = gcd(E, abs(A[i])); }
	
	vector<long long>P, Q;
	for (long long i = 2; i*i <= E; i++) {
		if (E%i == 0) {
			P.push_back(i);
			while (E%i == 0) E /= i;
		}
	}
	if (E >= 2) P.push_back(E);

	for (int i = 2; i <= 10000; i++) {
		bool flag = false;
		for (int j = 2; j*j <= i; j++) {
			if (i%j == 0) flag = true;
		}
		if (flag == false) P.push_back(i);
	}
	sort(P.begin(), P.end());
	P.erase(unique(P.begin(), P.end()), P.end());

	for (long long i : P) {
		long long mod = i;
		bool flag = false;

		for (long long t = -12; t <= 12; t++) {
			long long C = 0, D = 1;
			for (int j = 0; j <= N; j++) {
				C += D * A[j]; D *= t; D += mod * mod; D %= mod;
				C %= mod;
			}
			if (C != 0) { flag = true; break; }
		}

		if (flag == false) Q.push_back(i);
	}

	for (int i = 0; i < Q.size(); i++) cout << Q[i] << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
long long n, a[100100], f[100100], k;
int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 2; i <= n; i++)
        f[i] = 1e10;
    for (int i = 2; i <= k; i++)
        f[i] = abs(a[i] - a[1]);
    for (int i = k + 1; i <= n; i++)
    {
        for (int j = i - 1; j >= i - k; j--)
            f[i] = min((long long)(abs(a[i] - a[j]) + f[j]), f[i]);
    }
    cout << f[n];
}


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

using ll = long long;

#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SQR(x) (x) * (x)

void twi(const int& x, const int& y, const int& z){
    
}

int main(){
    vector<int> x(3);
    int k;
    cin >> x[0] >> x[1] >> x[2] >> k;
    REP(i, k){
        *max_element(x.begin(), x.end()) *= 2;
    }
    int sum = 0;
    REP(i, 3){
        sum += x[i];
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
#define MAX 200000
#define INFTY (1<<30)

template <class T>
T gcd(T n, T m){
    if (n>m) return gcd(m,n);
    else if(n==0) return m;
    else return gcd(m-n*(m/n), n);
}

ll war(ll a, ll b, ll d){
    return a/d - (b-1)/d;
}

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll lc = c*d/gcd(c, d);
    ll ans = war(b, a, c) + war(b,a,d) - war(b,a,lc);
    cout << b-a-ans + 1 << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

type problem struct {
	id, ac, wa int
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	problems := make([]problem, N)
	for i := 0; i < M; i++ {
		var p int
		var s string
		fmt.Scan(&p, &s)
		p--
		if s == "WA" {
			if problems[p].ac == 0 {
				problems[p].wa++
			}
		} else {
			if problems[p].ac == 0 {
				problems[p].ac++
			}
		}
	}
	var ac, wa int
	for i := 0; i < N; i++ {
		if problems[i].ac > 0 {
			ac++
			wa += problems[i].wa
		}
	}
	fmt.Println(ac, wa)
}


Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

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

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			StringTokenizer st = new StringTokenizer(line);

			int W, H, x, y, r;
			W = Integer.parseInt(st.nextToken());
			H = Integer.parseInt(st.nextToken());
			x = Integer.parseInt(st.nextToken());
			y = Integer.parseInt(st.nextToken());
			r = Integer.parseInt(st.nextToken());

			boolean res = true;
			if (x - r < 0) res &= false;
			if (x + r > W) res &= false;
			if (y - r < 0) res &= false;
			if (y + r > H) res &= false;

			System.out.println(res ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 17052
#include<iostream>
#include<cmath>
#include<map>
#include<queue>
using namespace std;

#define N 3
#define N2 9

struct Puzzle{
  int f[N2];
  int space;
  string path;

  bool operator < (const Puzzle &p) const{
    for(int i = 0; i < N2; i++){
      if(f[i] == p.f[i]) continue;
      return f[i] > p.f[i];
    }
    return false;
  }
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};

bool isTarget(Puzzle p){
  for(int i = 0; i < N2; i++){
    if(p.f[i] != (i + 1)) return false;
  }
  return true;
}

string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle, bool> V;
  Puzzle u, v;
  s.path = "";
  Q.push(s);
  V[s] = true;

  while( !Q.empty()){
    u = Q.front();
    Q.pop();
    if(isTarget(u)) return u.path;
    int sx = u.space / N;
    int sy = u.space % N;
    for(int i = 0; i < 4; i++){
      int tx = sx + dx[i];
      int ty = sy + dy[i];
      if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
      v = u;
      swap(v.f[u.space], v.f[tx * N + ty]);
      v.space = tx * N + ty;
      if(!V[v]){
	V[v] = true;
	v.path += dir[i];
	Q.push(v);
      }
    }
  }
  return "unsolvable";
}

int main(){
  Puzzle in;

  for(int i = 0; i < N2; i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }
  string ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}





Measured memory_bytes: 30608
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x; cin>>a>>b>>c>>x;
  int ans=0;
  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        if(500*i+100*j+50*k == x)
          ans++;
      }
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;

#define MAX 5432

class Union_Find{
public:
  int par[MAX],rank[MAX];
  Union_Find(int N){
    for(int i = 0 ; i < N ; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int find(int x){
    if(par[x] == x){
      return x;
    }
    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);
  }
};

int main(){
  int N,M,x[MAX];
  string a[MAX],s,t;
  map<string,int> mp;
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    cin >> a[i] >> x[i];
    mp[a[i]] = i;
  }
  Union_Find uf(N);
  cin >> M;
  while(M--){
    cin >> s >> t;
    uf.unite(mp[s],mp[t]);
  }
  int res = 0;
  for(int i = 0 ; i < N ; i++){
    int min = (1<<29);
    for(int j = 0 ; j < N ; j++){
      if(uf.same(i,j)){
        min = std::min(min,x[j]);
      }
    }
    res += min;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1884
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int beki(int K){
  if(K==0) return 1;
  else return 2*beki(K-1);
}

int main(){
  	int A, B, K;
    cin >> A >> B >> K;

    if(B-A>=2*K-1){
      for(int i=0;i<K;i++){
        cout << A + i <<endl;
      }
      for(int i=K-1;i>=0;i--){
        cout << B - i <<endl;
      }
      return 0;
    }
    
    for(int i=A;i<=B;i++){
      cout << i <<endl;
    }

  return 0;
}

Measured memory_bytes: 256
using System;

class ABC_125_A
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);
        int T = int.Parse(input[2]);

        int ans = (T / A) * B;

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using u64 = uint64_t;

int main() {
	u64 N, K;
	cin >> N >> K;
	
	vector<bool> sweets(N);
	
	for(u64 i=0; i<K; i++) {
		u64 d;
		cin >> d;
		
		for(u64 j=0; j<d; j++) {
			u64 A;
			cin >> A;
			
			sweets[A-1] = sweets[A-1] | true;
		}
	}
	
	u64 ans = 0;
	for(u64 i=0; i<N; i++) {
		ans += sweets[i];
	}
	
	cout << N - ans; 
	
	return 0;
}


Measured memory_bytes: 3624
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, P = mapint()
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
from collections import Counter
c = Counter(prime_factorize(P))

ans = 1
for num, cnt in c.most_common():
    if cnt<N:
        break
    ans *= num**(cnt//N)
print(ans)
        

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D){
    cout << "Balanced" << endl;
  }
  else if (A + B < C + D){
    cout << "Right" << endl;
  }
  // ここにプログラムを追記
}

Measured memory_bytes: 3568
#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(void)
{
   int64_t d,t,s;

   cin >> d >> t >> s;

   if(d%s == 0){
       if(d/s <= t){
           cout << "Yes" << endl;
       }else{
           cout << "No" << endl;
       }
   }else{
       if(d/s < t){
           cout << "Yes" << endl;
       }else{
           cout << "No" << endl;
       }
   }


}

Measured memory_bytes: 3632
N=int(input())
CSF=[[0]]+[list(map(int, input().split())) for _ in range(N-1)]

for j in range(1,N):
    t=0
    for i in range(j,N):
        if t<CSF[i][1]:
            t=CSF[i][1]
        elif t%CSF[i][2]!=0:
            t=t+CSF[i][2]-t%CSF[i][2]
        t+=CSF[i][0]
    print(t)
print(0)


Measured memory_bytes: 3188
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    // let n: usize = sc.cin();
    // let p: usize = sc.cin();
    let s: Vec<_> = sc.chars().iter().map(|&c| ((c as u8) - ('0' as u8)) as usize).collect();
    let n = s.len();
    let p = 2019;

    let mut memo = vec![0; p];
    memo[0] = 1;
    {
        let mut base = 1;
        let mut ac = 0;
        for &x in s.iter().rev() {
            ac += base * x;
            ac %= p;
            memo[ac] += 1;
            base = (base * 10) % p;
        }
    }
    let mut ans = 0;
    for x in 0..p {
        if memo[x] > 1 {
            ans += memo[x] * (memo[x] - 1) / 2;
        }
    }
    put!(ans);

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4320
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
  ll n,m,tmp=0,ans=0;cin>>n>>m;
  if(n>2){
    if(m>2){ans=(n-2)*(m-2);}
    else if(m==1){ans=n-2;}
  }
  else if(n==1){
    if(m>2){ans=m-2;}
    else if(m==1){ans=1;}
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 384
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn bottom_up(vs: &Vec<Vec<usize>>, sub_pattern: &mut Vec<i64>, children: &mut Vec<Vec<(usize, i64)>>, v: usize, m: i64) -> i64 {
  let mut pat = 1;
  sub_pattern[v] = 1;
  for &u in vs[v].iter() {
    if sub_pattern[u] >= 0 {
      continue;
    }
    let p = bottom_up(vs, sub_pattern, children, u, m);
    pat = (pat * (p + 1)) % m;
    children[v].push((u, p));
  }
  sub_pattern[v] = pat;
  pat
}

fn top_down(sub_pattern: &Vec<i64>, children: &Vec<Vec<(usize, i64)>>, pattern: &mut Vec<i64>, par_pattern: i64, v: usize, m: i64) {
  pattern[v] = (par_pattern + 1) * sub_pattern[v] % m;
  let mut left_scan = vec![1i64; children[v].len() + 1];
  for (i, &(_, p)) in children[v].iter().enumerate() {
    left_scan[i+1] = left_scan[i] * (p + 1) % m;
  }
  let mut right_scan = vec![1i64; children[v].len() + 1];
  for (i, &(_, p)) in children[v].iter().enumerate().rev() {
    right_scan[i] = right_scan[i+1] * (p + 1) % m;
  }
  for (i, &(u, _)) in children[v].iter().enumerate() {
    let pp = left_scan[i] * right_scan[i+1] % m * (par_pattern + 1) % m;
    top_down(sub_pattern, children, pattern, pp, u, m);
  }
}

fn main() {
  input! {
    n: usize,
    m: i64,
    xys: [(usize1, usize1); n-1]
  }
  let mut vs = vec![vec![]; n];
  for &(x, y) in xys.iter() {
    vs[x].push(y);
    vs[y].push(x);
  }
  let mut sub_pattern = vec![-1i64; n];
  let mut children = vec![vec![]; n];
  bottom_up(&vs, &mut sub_pattern, &mut children, 0, m);
  let mut pattern = vec![0i64; n];
  top_down(&sub_pattern, &children, &mut pattern, 0, 0, m);
  for &p in pattern.iter() {
    println!("{}", p);
  }
}


Measured memory_bytes: 38208
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
#define enld endl
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int T; cin >> T;
    if(T >= 30) cout << "Yes" << endl;
    else cout << "No" << enld;
    return 0;
}

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

int main(){
 ll a,b,n;
 cin>>a>>b>>n;
 ll l=0,r=n;
 ll ans=-1;
  while(l<=r){
    ll  mid = l+(r-l)/2;
    ll k = floor(a*mid/(1.0*b) ) - a*floor(mid/(1.0*b));
      if(ans<=k){
          ans=k;
        l=mid+1;
      }else
      r=mid-1;
  }
  cout<<ans;
}


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

long lcm(long x, long y){
  long tmp, r, a;
  a = x * y;
  if(x < y){
    tmp = x;
    x = y;
    y = tmp;
  }
  r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return a / y;
}

int main(){
  long long int a, b, c, d;
  cin >> a >> b >> c >> d;
  a--;
  long long int ac, ad, ae, bc, bd, be, ans;
  ac = a / c;
  ad = a / d;
  ae = a / lcm(c,d);
  bc = b / c;
  bd = b / d;
  be = b / lcm(c,d);
  ans = b - a - (bc + bd - be - ac - ad + ae);
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  cout << (s == "ABC" ? "ARC" : "ABC") << endl;
  return 0;
}

Measured memory_bytes: 3652
import java.util.*; 
import java.io.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        int N = nextInt();
        long D = nextInt();

        int ans = 0;

        for (int i=0; i<N; i++) {
            long x = nextInt();
            long y = nextInt();
            if(D*D>=x*x+y*y){
                ans ++;
            }
        }

        System.out.println(ans);
 
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}


Measured memory_bytes: 54272
#include <bits/stdc++.h>
using namespace std;
long long n , p , ans=0;
bool a , b , c;
void k(long long x){
  if(x <= n){
    if(x > 100){
      a = b = c = false;
      p = x;
      while(p>0){
        if(p%10 == 3){
          a=true;
        } else if (p%10 == 5){
          b=true;
        } else if (p%10 == 7){
          c=true;
        }
        p/=10;
      }
      if(a && b && c){
        ans++;
      }
    }
    k(x*10+3) , k(x*10+5) , k(x*10+7);
  }
}

signed main(){
  cin>>n;
  k(3) , k(5) , k(7);
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;
const int  Inv2 = (MOD+1)/2;

     signed main(){
 int n,m;
 cin>>n>>m;
 cout<<(n-1)*(m-1)<<endl;
   }
         


        


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

int v[10];

void dfs(int r, int D, int x, int t)
{
	if(t == 10) return;

	v[t] = ((r * x) - D);
	cout << v[t] << endl;
	dfs(r, D, v[t], t + 1);

	return;
}

int main(void) {

	int r, D, x;
	cin >> r >> D >> x;

	dfs(r, D, x, 0);
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll x;
    cin >> x;
 
    ll a = x/11;
    ll b = x%11;
    if(b == 0) {
        out(2*a);
    }
    else if(b <= 6) {
        out(2*a + 1);
    }
    else {
        out(2*a + 2);
    }
 
    re0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		
		while(scan.hasNext()){
			int[] aNums = new int[4];
			int[] bNums = new int[4];
			int hit = 0;
			int blow = 0;
			for(int i = 0; i < 4; i++){
				aNums[i] = scan.nextInt();
			}
			for(int i = 0; i < 4; i++){
				bNums[i] = scan.nextInt();
			}
			for(int i = 0; i < 4; i++){
				for(int j = 0; j < 4; j++){
					if(aNums[i] == bNums[j]){
						if(i == j){
							hit++;
						} else{
							blow++;
						}
					}
				}
			}
			System.out.printf("%d %d\n", hit, blow);
		}
	}
}

Measured memory_bytes: 26156
x, y = map(int, input().split())

ans = 0

if x >= 0 and y >= 0:
    if y >= x:
        ans = y - x
    else:
        ans = abs(y-x) + 2
elif x >= 0 and y < 0:
    ans = abs(abs(y)-abs(x)) + 1

elif x < 0 and y >= 0:
    ans = abs(abs(y)-abs(x)) + 1

else:
    if y >= x:
        ans = abs(y-x)
    else:
        ans = abs(y-x) + 2

if y == 0:
    ans -= 1

print(ans)

Measured memory_bytes: 3064
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v = i*i+j*j+k*k+i*j+j*k+k*i;
      if v<10050:
        ans[v]+=1
for i in range(n):
  print(ans[i+1])


Measured memory_bytes: 9264
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<Integer> d = new ArrayList<>();
        for (int i=0; i<N; i++) {
            d.add(sc.nextInt());
        }
        
        int count = 0;
        for (int s=0; s<d.size()-1; s++) {
            for (int s2=s+1; s2<d.size(); s2++) {
                count += d.get(s)*d.get(s2);
            }
        }
        System.out.println(count);
        
    }
}

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

//テストケースはあんまり見ないほうが良い。デバッグする能力が必要.
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int ans = 0;
    rep(i, n)
    {
        if (h[i] >= k)
            ++ans;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int[][] dp = new int[s.length() + 3][t.length() + 3];
		for(int i = 0 ; i < s.length() ; i++) {
			for(int j = 0 ; j < t.length() ; j++){
				if(s.charAt(i) == t.charAt(j)) {
					dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1],dp[i][j] + 1);
				}
				dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1],dp[i][j + 1]);
				dp[i + 1][j + 1] = Math.max(dp[i + 1][j + 1],dp[i + 1][j]);
			}
		}
		String ans = "";
		StringBuilder sb = new StringBuilder(ans);

		int i = s.length();
		int j = t.length();

		while(i > 0 && j > 0) {
			if(dp[i][j] == dp[i - 1][j])
				i--;
			else if(dp[i][j] == dp[i][j - 1])
				j--;
			else {
				sb.append(s.charAt(i - 1));
				i--;
				j--;
			}

		}
		System.out.println(sb.reverse().toString());

	}
}



Measured memory_bytes: 86312
#include<stdio.h>
int main(void){
	char A[1201];
	int i=0;
	int a;
	
	gets(A);
	a=strlen(A);
	
	//for(i=0;i<a;i++){
	while(1){
		if(A[i]>=65 && A[i]<=90){
			A[i]+=32;
		}else if(A[i]>=97 && A[i]<=122){
			A[i]-=32;
		}
		
		i++;
		if(i==a)break;
		//if(A[i]=='\0')break;
	}
	puts(A);
	
	return 0;
}

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

int main(){
    int s_x, s_y, t_x, t_y;
    cin >> s_x >> s_y >> t_x >> t_y;

    int side = t_x - s_x;
    int higt = t_y - s_y;

    for(int i = 0; i < higt; i++){
        cout << "U";
    }
    for(int i = 0; i < side; i++){
        cout << "R";
    }
    for(int i = 0; i < higt; i++){
        cout << "D";
    }
    for(int i = 0; i < side; i++){
        cout << "L";
    }

    cout << "L";
    for(int i = 0; i <= higt; i++){
        cout << "U";
    }
    for(int i = 0; i <= side; i++){
        cout << "R";
    }
    cout << "DR";
    for(int i = 0; i <= higt; i++){
        cout << "D";
    }
    for(int i = 0; i <= side; i++){
        cout << "L";
    }
    cout << "U" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		StringBuffer strr = new StringBuffer(str.length());
		for (int i = str.length() - 1; i >= 0; i--) {
			strr.append(str.substring(i, i+1));
		}
		System.out.println(strr);
	}

}

Measured memory_bytes: 17124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=100005;
int x[N],y[N],t[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n;
  cin>>n;
  rep(i,1,n+1)
    cin>>t[i]>>x[i]>>y[i];
  rep(i,1,n+1)
    {
      int tmp=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
      int diff=t[i]-t[i-1];
      if(tmp>diff || ((diff-tmp)&1))
	{
	  cout<<"No"<<endl;
	  return 0;
	}
    }
  cout<<"Yes"<<endl;
  return 0 ;
}


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

using namespace std;

int main()
{
    int N;
    int s[101];
    int ans = 0;

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> s[i];
        ans += s[i];
    }

    sort(s, s+N);

    if (ans % 10 != 0)
        cout << ans << endl;
    else {
        for (int i = 0; i < N; i++) {
            if (s[i] % 10 != 0) {
                ans -= s[i];
                break;
            }
        }
        if (ans % 10 == 0)
            cout << 0 << endl;
        else
            cout << ans << endl;
    }

    return 0;
}

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

int n, k, h[200004];

int main() {
	cin>>n>>k;
	for(int i = 0; i < n; i++)	cin>>h[i];
	sort(h, h+n);
	if(n <= k)	cout<<"0";
	else{
		long long ret = 0;
		for(int i = 0; i < n-k; i++)	ret += h[i];
		cout<<ret;
		
	}
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int a, b, c, x, y;
int ans;

int main() {
	scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
	int sum = a * x + b * y;
	int s = min(x, y) * 2 * c;
	if(x >= y) s += (x - y) * a;
	else s += (y - x) * b;
	int s0 = max(x, y) * 2 * c;
	s = min(s, s0);
	ans = min(sum, s);
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
const int MAXN = 1e5+5;
char S[MAXN];
int K, N;

int solve() {
  int A = 0;
  for (int i = 0; i < N; ++i) {
    if ((S[i] == 'L') && (i > 0) && (S[i-1] == S[i])) ++A;
    if ((S[i] == 'R') && (i+1 < N) && (S[i+1] == S[i])) ++A;
  }
  return std::min(N-1, A+2*K);
}

int main() {
  scanf(" %d%d%s", &N, &K, S);
  printf("%d\n", solve());
  return 0;
}

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

int w,a,b,x,y;
int main()
{
    cin >> w >> a >> b;
    x = w + a;
    y = w + b;
    
    if (a>y)
    {
        cout << a - y << endl;
    }
    else if (x<b)
    {
        cout << b - x << endl;
    }
    else
    {
        cout << 0 << endl;
    }

return 0;
}

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

using namespace std;

int main() {
	const Int MOD = 1e9 + 7;
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	vector<Int> cnt(N + 1, 0);
	cnt[0] = 3;
	Int ans = 1;
	for (int i = 0; i < N; ++i) {
		(ans *= cnt[a[i]]) %= MOD;
		--cnt[a[i]];
		++cnt[a[i] + 1];
	}
	cout << ans % MOD << endl;

	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;
 
int main(){
    ll N;
    cin>>N;
    VL a(N);
    rep(i,0,N){
        cin>>a[i];
    }
    ll ans=0;
    while(true){
        rep(j,0,N){
            if(a[j]%2==0)a[j]/=2;
            else if(a[j]%2!=0){cout<<ans<<endl;return 0;}
        }
        ans++;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  int a,b,c,k;
  scanf("%d%d%d%d",&a,&b,&c,&k);
  if (k<=a)
    printf("%d\n",k);
  else if (k>a && k<=(a+b))
    printf("%d\n",a);
  else if (k>(a+b) && k<=(a+b+c))
    printf("%d\n",(a-(k-a-b)));
  else
    printf("%d\n",(a-c));
  return 0;
}

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

const int MOD = 1000000007;
const int MAXH = 1005;
const int MAXW = 1005;

void add(int &a, int b) { a += b; if(MOD <= a) a -= MOD; }

int dp[MAXH][MAXW];
char A[MAXH][MAXW];

int H, W;

int main() {
	scanf("%d%d", &H, &W);
	dp[1][1] = 1;
	for(int i = 1; i <= H; i++) {
		scanf(" %s", A[i]+1);
		for(int j = 1; j <= W; j++) if('.' == A[i][j]) {
			add(dp[i][j], dp[i-1][j]);
			add(dp[i][j], dp[i][j-1]);
		}
	}

	cout << dp[H][W] << endl;
	return 0;
}

Measured memory_bytes: 5120
#include<stdio.h>


int main(){
int a[3];
int i,j;
int s;
int n;
int k;

scanf("%d",&n);

for(k=0;k<n;k++){
for(i=0;i<3;i++){
scanf("%d",&a[i]);
}

for(i=0;i<3;i++){
for(j=2;j>i;j--){
if(a[j-1]>a[j]){
s=a[j];
a[j]=a[j-1];
a[j-1]=s;
	}
	}
	}	

if(a[2]*a[2]==a[1]*a[1]+a[0]*a[0]) printf("YES");
else printf("NO");

printf("\n");

}

return 0;
	}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
//ofstream fout("output.txt");
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define en "\n"
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(0);
#define pi 4*atan(1)
#define f(n) for(int i=0;i<n;++i)
#define fab(a,b) for(int i=a;i<=b;++i)
#define fba(b,a) for(int i=b;i>=a;--i)
#define reset(a,x) memset(a,x,sizeof(a))
typedef pair<int,int> ipair;
typedef vector<int> vi;
vector<ll>v;

int main()
{
    IOS
    cin.tie(0);

    int a,b,c;
    cin>>a>>b>>c;
    int k;
    cin>>k;
    int ans=0;
    if(k<=a){
        cout<<k<<endl;
        return 0;
    }
    else{
        k-=a;
        ans+=a;

    }

    if(k<=b){
        cout<<ans<<endl;
        return 0;
    }
    else{
        k-=b;
    }

    cout<<ans-k<<endl;




    return 0;
}


Measured memory_bytes: 3620