akhauriyash/Code-Regression huggingface dataset:
N=int(input())
data=[]
for i in range(N):
    d=list(input().split())
    d[1]=int(d[1])
    d.append(i+1)
    data.append(d)
data.sort()
mem=[]; current=''
ans=[]
for i in data:
    if current!=i[0]:
        current=i[0]
        mem.sort(key=lambda x:x[1])
        d=[0]*len(mem)
        for j in range(len(mem)): d[len(mem)-(j+1)]=mem[j][2]
        ans.extend(d)
        mem=[i]
    else: mem.append(i)
mem.sort(key=lambda x:x[1])
d=[0]*len(mem)
for j in range(len(mem)): d[len(mem)-(j+1)]=mem[j][2]
ans.extend(d)
mem=[i]
for i in ans: print(i)

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

ll n;
vector<vector<ll>> v(100010);
ll a[100010];
bool used[100010];

bool pos = true;

ll dfs(ll p){
    used[p] = true;

    bool leaf = true;
    ll sum = 0, M = 0;
    for(auto i:v[p]){
        if(!used[i]){
            ll t = dfs(i);
            leaf = false;
            M = max(M,t);
            sum += t;
        }
    }
    if(leaf) return a[p];

    ll mxp = min(sum - M,sum/2);

    if(sum<a[p] || a[p] < sum - mxp){
        cout << "NO\n";
        exit(0);
    }
    ll ret = a[p] - (sum - a[p]);
    //if( (sum-a[p]) <= min(sum - M,sum/2) ){
        return ret;
    //}
    // pos = false;
    // return -1;
}

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

    

    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    int root=0;
    for(ll i=0;i<n-1;i++){
        ll r,b;
        cin>>r>>b;
        r--,b--;
        v[r].push_back(b);
        v[b].push_back(r);
        if(v[r].size()>1) root = r;
        if(v[b].size()>1) root = b;
    }

    if(n==2 && a[0]==a[1]){
        cout<<"YES"<<endl;
        return 0;
    }
    else if(n==2) {
        cout<<"NO"<<endl;
        return 0;
    }
    

    ll r = dfs(root);

    if(pos && r==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
const double PI = acos(-1.0);
const long mod = 1000000007;
const long INF = 1e9 + 1;

int main() {
  int n,m,a[10][10];
  cin >> n >> m;
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= n; j++) a[i][j] = 0;
  }
  for(int i = 0; i < m; i++) {
    int x,y; cin >> x >> y;
    a[x][y] = 1; a[y][x] = 1;
  }

  vector<int> b;
  for(int i = 0; i < n; i++) b.push_back(i+1);
  int cnt = 0;
  do {
    bool flag = 0;
    for(int i = 0; i < n-1; i++) {
      if(a[b[i]][b[i+1]] == 1) flag = 1;
      else {
        flag = 0; break;
      }
    }
    if(flag) cnt++;
  } while(next_permutation(b.begin()+1,b.end()));

  cout << cnt << endl;
}

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

int main()
{
    int  a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
    cin>>a>>b;
    x=a-1;
    y=b-x;
    z=b+x;
    for(int i=y;i<=z;i++)
    {
        cout<<i<<endl;
    }

   // cout<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define MAXN 200010
using namespace std;
struct pos{
    int val;
    int th;
};
int n;
pos a[MAXN];
int map[MAXN];
bool cmp(pos a,pos b){
    if(a.val<b.val)
        return true;
    else return false;
}
int main(){
    cin>>n;
    for(int i=1; i<=n ;i++){
        scanf("%d",&a[i].val);
        a[i].th=i;
    }
    sort(a+1,a+n+1,cmp);

    for(int i=1; i<=n; i++){
        map[a[i].th] = i;
    }

    for(int i=1; i<=n; i++){
        if(map[i]<=n/2){
            printf("%d\n",a[n/2+1].val);
        }
        else
            printf("%d\n",a[n/2].val);
    }
    return 0;
}

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

int main() {
  int N, A;
  
  cin >> N >> A ;
  
  if ( A >= N % 500 ) {
    cout << "Yes" << endl;
  }
  else if ( A < N % 500 ) {
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int64 k;
  cin >> n >> k;
  vector<int> a;
  vector<int> b;
  int z = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (x < 0) {
      a.push_back(x);
    } else if (x > 0) {
      b.push_back(x);
    } else {
      ++z;
    }
  }
  sort(begin(a), end(a));
  sort(begin(b), end(b));
  auto ra = a, rb = b;
  reverse(begin(ra), end(ra));
  reverse(begin(rb), end(rb));
  auto f = [&] (int64 mid) {
    int64 res = 0;
    if (mid >= 0) {
      res += z * 1ll * (a.size() + b.size());
      res += z * 1ll * (z - 1) / 2;
    }
    int i = 1;
    for (int x : a) {
      auto cmp = [&] (int64 l, int64 r) {
        return l < r * x;
      };
      res += upper_bound(begin(rb), end(rb), mid, cmp) - begin(rb);
      res += upper_bound(begin(ra), end(ra) - i, mid, cmp) - begin(ra);
      ++i;
    }
    i = 1;
    for (int x : b) {
      auto cmp = [&] (int64 l, int64 r) {
        return l < r * x;
      };
      res += upper_bound(begin(b) + i, end(b), mid, cmp) - begin(b) - i;
      ++i;
    }
    return res;
  };
  int64 l = -inf64, r = inf64;
  while (l < r) {
    int64 mid = (l + r + 1) / 2;
    if (f(mid) < k) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  cout << l + 1 << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 1908
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <stack>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
//#include <unordered_set>
#define INF 2147483647
#define MAXN  200005
#define mod 1000000007
#define PII pair<int, int>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int dx[100005];
int gcd(int a, int b)
{
	return b == 0 ? a : gcd(b, a%b);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef local_debug
	ifstream inputs("input.txt");
	cin.rdbuf(inputs.rdbuf());
	freopen("input.txt", "r", stdin);
#endif
	ll sum;
	int n, at, d, i;
	char s1[54], s2[54];
	while (cin >> n)
	{
		cin.ignore();
		cin.getline(s1, n+1);
		cin.getline(s2, n+1);
		//cout << s1 << endl;
		//cout << s2 << endl;
		i = 0;
		sum = 1;
		at = -1;
		while (i < n)
		{
			if (i == 0)
			{
				if (s1[i] == s2[i])
				{
					sum *= 3;
					at = 1;
					i++;
				}
				else
				{
					sum *= 6;
					at = 2;
					i += 2;
				}
			}
			else
			{
				if (at == 1)
				{
					if (s1[i] == s2[i])
					{
						sum *= 2;
						sum %= mod;
						at = 1;
						i++;
					}
					else
					{
						sum *= 2;
						sum %= mod;
						at = 2;
						i += 2;
					}
				}
				else
				{
					if (s1[i] == s2[i])
					{
						//sum *= 1;
						sum %= mod;
						at = 1;
						i++;
					}
					else
					{
						sum *=3;
						sum %= mod;
						at = 2;
						i += 2;
					}
				}
			}
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 256
program redistribution
  implicit none
  integer(8), parameter :: modu = 1000000007
  integer :: s, i
  integer(8) :: dp(2000) = 0
  read(*,*) s
  dp(3) = 1
  do i = 4, s
    dp(i) = mod(dp(i - 1) + dp(i - 3), modu)
  end do
  write(*,'(i0)') dp(s)
end program redistribution

Measured memory_bytes: 2832
#include<bits/stdc++.h>
using namespace std;
using int64 = long long;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793

  int main()
{
  long long N,M,ans,W;
  bool flag=false;
  scanf("%lld",&N);
  scanf("%lld",&ans);
  
  if(ans==0){
    cout<<0;
    return 0;
  }
  for(int i=1;i<N;i++){
  scanf("%lld",&W);
    if(W==0){
      printf("%d",0);
      return 0;
    }
    if(W <=1000000000000000000/ ans ){
      ans*=W;
    }else{
      flag=true;
    }
    /*M=ans;
    ans*=W;
    if(ans/W!=M){
      flag=true;
    }
    if(INF<ans){
      flag=true;
    }*/

  }
  if(flag)printf("%d",-1);
  else printf("%lld",ans);
  return 0;
}



Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    rep(i,5){
        ll x; cin >> x;
        if(x == 0)cout << i + 1 << endl;
    }
}

Measured memory_bytes: 3536
#include<cstdio>
#include<algorithm>
using namespace std;

int n, x, f = 1;
int a[200010];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	for (int i = 1; i < n; i++)
		if (a[i] == a[i + 1]) {
			f = 0;
			break;
		}
	if (f == 1) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
int main(void){
    int n,m;m=0;
    scanf("%d",&n);
    char s[n+2];
    s[0]='A';
    scanf("%s",s+1);
    for(int i=1;i<=n;i++){
        if(s[i]!=s[i-1])m++;
    }
    printf("%d\n",m);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//





int main() {
    
    int N, M; cin >> N >> M;
    vector<int> a(M); rep(i,M) cin >> a[i];
    vector<ll> dp(N+1);
    rep(i,N+1) dp[i] = 0;
    rep(i,M) dp[a[i]] = -1;
    dp[0] = 1;
    if (dp[1] == -1) dp[1] = 0;
    else dp[1] = 1;
    for (int i = 2; i <= N; ++i) {
        if (dp[i] == -1) dp[i] = 0;
        else dp[i] = (dp[i-2] + dp[i-1]) % MOD;
    }
    out(dp[N]);
    
    return 0;
}






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

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

        public static void Solve()
        {
            var ab = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(ab[1] % ab[0] == 0 ? ab[0] + ab[1] : ab[1] - ab[0]);
        }
    }
}


Measured memory_bytes: 13396
#include "bits/stdc++.h"
using namespace std;
#define INF 1<<30
#define LINF 1LL<<60

struct edge {
	int to; // ?????????
	int cap; // ??????
	int rev; // ??????
	edge() {}
	edge(int to, int cap, int rev) :to(to), cap(cap), rev(rev) {}
};

vector<vector<edge>> G; // ??°???????????£??\???????????¨???
vector<int> used; // DFS??§?????§???????????????????????°

// from??????to??????????????????cap???????????°?????????????????????
void add_edge(int from, int to, int cap) {
	G[from].push_back(edge(to, cap, G[to].size()));
	G[to].push_back(edge(from, 0, G[from].size() - 1));
}

// ?¢?????????????DFS??§??¢???
int dfs(int v, int t, int f) {
	if (v == t) return f;
	used[v] = true;
	for (int i = 0; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

// s??????t???????????§???????±???????
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		fill(used.begin(), used.end(), 0);
		int f = dfs(s, t, INF);
		if (f == 0) return flow;
		flow += f;
	}
}


/* use example */
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int V, E; cin >> V >> E;
	G.resize(V); used.resize(V);
	for (int i = 0; i < E;i++) {
		int s, t, c; cin >> s >> t >> c;
		add_edge(s, t, c);
	}
	cout << max_flow(0, V - 1) << endl;
	return 0;
}

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmallLargeOrEqual
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力
            string str = Console.ReadLine();
            string[] arr = str.Split(' ');

            //文字を整数型に変換する
            int a = int.Parse(arr[0]);
            int b = int.Parse(arr[1]);

            //比較＆出力
            //if文を使おう
            if (a < b)
            {
                Console.WriteLine("a < b");
            }
            else  
            {
                if (a > b)
                {
                    Console.WriteLine("a > b");
                }
                else
                {
                    Console.WriteLine("a == b");
                }
                
                 
                
            }

        }
    }
}



Measured memory_bytes: 15940
#include<stdio.h>

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

	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k);
	if ((e - a) <= k)
		printf("Yay!");

	if ((e - a) > k)
		printf(":(");

	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
 
SUM = [0]
ans = 10**20
for a in A:
    SUM.append(SUM[-1]+a)

# P < Qとなるような区切れ目を探す
def binary_search1(a, ok, ng, i):
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2
        if a[mid] < a[i]-a[mid]: ok = mid
        else: ng = mid
    return ok

# R < Sとなるような区切れ目を探す
def binary_search2(a, ok, ng, i):
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2
        if a[mid]-a[i] < a[N]-a[mid]: ok = mid
        else: ng = mid
    return ok

for i in range(2,N-1): # [1,i]と(i,N]に分割
    m = binary_search1(SUM, 0, i+1, i)
    P1, Q1 = SUM[m], SUM[i]-SUM[m]
    P2, Q2 = SUM[m+1], SUM[i]-SUM[m+1]
    if abs(P1-Q1) < abs(P2-Q2): P, Q = P1, Q1
    else: P, Q = P2, Q2
    m = binary_search2(SUM, i, N+1, i)
    R1, S1 = SUM[m]-SUM[i], SUM[N]-SUM[m]
    R2, S2 = SUM[m+1]-SUM[i], SUM[N]-SUM[m+1]
    if abs(R1-S1) < abs(R2-S2): R, S = R1, S1
    else: R, S = R2, S2
    ans = min(max(P,Q,R,S) - min(P,Q,R,S), ans)
print(ans)



Measured memory_bytes: 102484
#include<bits/stdc++.h>
#define maxn 100005
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
int n;
char s[maxn];
ll cnt[maxn][27];
int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=n;i>=1;i--){
		int id=s[i]-'a'+1;
		for(int j=1;j<=26;j++) cnt[i][j]=cnt[i+1][j];
		cnt[i][id]++;
	}
	
	ll ans=0;
	for(int i=1;i<=n;i++){//以i为开头 
		int id=s[i]-'a'+1;
		ll calc=1;
	    for(int j=1;j<=26;j++){
	    	if(j==id) continue;
	    	calc=calc*(cnt[i+1][j]+1ll)%mod;
		}
		ans=(ans+calc)%mod;
	}
	printf("%lld",ans);
	
	
	return 0;
}

Measured memory_bytes: 21376
#include <bits/stdc++.h>
#define length(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
 
int main() {
  string day;
  cin >> day;
  string days[7] = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
  for(int i = 0;i < length(days);i ++){
    if(days[i].compare(day) == 0){
      cout << (i + 1) << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
/**
 * @Author:      G_bg
 * @DateTime:    2019-07-27 22:04:55
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn = 1e5+10;
int dp[maxn][13];
int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);cin.tie(0);
    string str;
    cin >> str;
    int p = 1;
    for(int i = str.length()-1;i >= 0;i--){
        if(str[i] == '?'){
            if(i == str.length()-1){
                for(int j = 0;j < 10;j++)
                    dp[i][j] = 1;
            }else{
                for(int j = 0;j < 10;j++)
                    for(int k = 0;k < 13;k++){
                        int remain = (p*j+k)%13;
                        dp[i][remain] = (dp[i][remain]+dp[i+1][k])%mod;
                    }
            }
        }else{
            if(i == str.length()-1)
                dp[i][str[i]-'0']++;
            else{
                for(int k = 0;k < 13;k++){
                    int remain = (p*(str[i]-'0')+k)%13;
                    dp[i][remain] = (dp[i][remain]+dp[i+1][k])%mod;
                }
            }
        }
        p = p*10%13;
    }
    cout << dp[0][5] << endl;
    //system("pause");
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main() {
    ll ans=0;
    ll n,a,b;cin >>n>>a>>b;
    ans=(n/(a+b))*a;
    n%=(a+b);
    ans+=min(a,n);
    cout <<ans <<endl;
}


Measured memory_bytes: 3540
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }




int main() {
    ll h, w, k;
    cin >> h >> w >> k;
    if(w == 1){
        cout << 1 << endl;
        return 0;
    }
    ll dp[105][15] = {};
    dp[0][0] = 1;
    REP(i, h){
        REP(j, (1 << (w - 1))){
            bool f = false, ok = true;
            REP(l, (w - 1)){
                if((j >> ((w - 1) - l - 1)) & 1){
                    if(f){
                        ok = false;
                    }
                    else{
                        f = true;
                    }
                }
                else{
                    f = false;
                }
            }
            
            if(!ok) continue;
            
            
            REP(l, w - 1){
                if((j >> ((w - 1) - l - 1)) & 1){
                    dp[i + 1][l + 1] += dp[i][l];
                    dp[i + 1][l] += dp[i][l + 1];
                    dp[i + 1][l + 1] %= MOD;
                    dp[i + 1][l] %= MOD;
                    l++;
                }
                else{
                    dp[i + 1][l] += dp[i][l];
                    dp[i + 1][l] %= MOD;
                }
            }
            if(!(j & 1)){
                dp[i + 1][w - 1] += dp[i][w - 1];
                dp[i + 1][w - 1] %= MOD;
            }
        }
    }
    
    /*
    REP(i, h + 1){
        REP(j, w + 1){
            cout << dp[i][j] << ' ';
        }
        cout << endl;
    }
    */
    
    cout << dp[h][k - 1] % MOD << endl;
}

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

using namespace std;
using ll = long long;

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x.at(i); }

int main() {

    int n = 5;
    CINS(int, a, n);

    int one = 10;
    int temp = 0;
    int sum = 0;

    for (int i = 0; i < n; i++) {
        if (a.at(i) % 10 > 0 && a.at(i) % 10 < one ) {
            one = a.at(i) % 10;
            temp = i;
        }
    }
    if (temp==0) {
        temp = 0;
    }

    for (int i = 0; i < n; i++) {
        if (i==temp) {sum += a.at(i);} else{
            sum += (a.at(i)+10-1)/10*10;
        }
    }
    

    cout << sum;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	var xx [4]int
	var yy [4]int

	for i := 0; i < 2; i++ {
		xx[i] = getNextInt(scanner)
		yy[i] = getNextInt(scanner)
	}

	for i := 2; i < 4; i++ {
		xx[i] = xx[i-1] - yy[i-1] + yy[i-2]
		yy[i] = yy[i-1] + xx[i-1] - xx[i-2]
	}

	fmt.Fprintf(writer, "%d %d %d %d\n", xx[2], yy[2], xx[3], yy[3])

	writer.Flush()
}


Measured memory_bytes: 640
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int n=in.nextInt(),c=0;
    int arr[]=new int[n];
    for(int i=0;i<n;i++)
    {
      arr[i]=in.nextInt();
      if(arr[i]%2!=0 && (i+1)%2!=0)
      {
        c++;
      }
    }
      System.out.println(c);
  }
}

Measured memory_bytes: 35564
#include<stdio.h>
int main()
{
	int a[101][101]={0};
    int r,c;
    scanf("%d %d",&r,&c);
    for(int i=0;i<r;i++)
    {
    	for(int j=0;j<c;j++)
    	{
    		scanf("%d",&a[i][j]);
    	}
    }
     for(int i=0;i<r;i++)
     {
  	   for(int j=0;j<c;j++)
  	   {
  		 a[i][c]=a[i][c]+a[i][j];
  	   }
     }
  for(int j=0;j<=c;j++)
  {
  	for(int i=0;i<r;i++)
  	{
  		a[r][j]=a[r][j]+a[i][j];
  	}
  }
  
  for(int i=0;i<=r;i++)
  {
  	for(int j=0;j<=c;j++)
  	{
  		printf("%d",a[i][j]);
  		if(j!=c) printf(" ");
  	}
  	printf("\n");
  }
    return 0;
}

Measured memory_bytes: 1080
#include<stdio.h>
int main(void)
{
	int a,b,c,x,i,s,g,j,k;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&x);
	s=0;
	g=0;
	for(i=0;i<=a;i++){
		for(j=0;j<=b;j++){
			for(k=0;k<=c;k++){
				if(x==500*i+100*j+50*k){
					s=s+1;
				}
		}
	}
	}
	printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

#define no cout << "No" << endl; exit(0)

int main(){
    int N;
    cin >> N;
    int t[N], v[N];
    cins(t, t + N);
    cins(v, v + N);
    int speed_twice = 0;
    double ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < t[i] * 2; j++){
            int next_speed_twice = min(speed_twice + 1, v[i] * 2);
            int dist = t[i] * 2 - j - 1;
            for(int k = i + 1; k < N; k++){
                next_speed_twice = min(next_speed_twice, v[k] * 2 + dist);
                dist += t[k] * 2;
            }
            next_speed_twice = min(next_speed_twice, dist);
            ans += (speed_twice + next_speed_twice) / 8.0;
            speed_twice = next_speed_twice;
        }
    }
    fcout << ans << endl;
}


Measured memory_bytes: 256
"use strict";

function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0], 10);
  var K = parseInt(input[0].split(" ")[1], 10);
  var S = [...input[1]].map(function (v) {
    return parseInt(v, 10);
  });
  var array = [];
  var now = 1;
  var localLen = 0;

  for (var i = 0; i < N; i++) {
    if (S[i] === now) {
      localLen++;
    } else {
      array.push(localLen);
      now = S[i];
      localLen = 1;
    }
  }

  array.push(localLen);

  if (array.length % 2 == 0) {
    array.push(0);
  } //console.log(array);


  var sum = [0];

  for (var _i = 0; _i < array.length; _i++) {
    sum.push(sum[_i] + array[_i]);
  } //console.log(sum);


  var max = 0;

  for (var _i2 = 0; _i2 < array.length; _i2 += 2) {
    var left = _i2;
    var right = Math.min(_i2 + 2 * K + 1, array.length); //console.log(left, right);

    var lSum = sum[right] - sum[left]; //console.log(sum[right], sum[left]);

    max = Math.max(max, lSum);
  }

  console.log(max);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 24984
#include <iostream>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
	int h = 0, w = 0;

	while (1){
		cin >> h >> w;
		if (h == 0 && w == 0){ break; }
		for (int i = 0; i < h;i++){
			for (int s = 0; s < w; s++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 1116
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(V) (V).begin(), (V).end() 
#define x first
#define y second

using namespace std;

typedef long long ll;
template <typename T> using V = vector <T>;
const ll mod = 1e9 + 7;
int ls[1020000], dp[1200000];
int main() {fio;
	int n;
	cin >> n;
	vector <int> a = {(int)2e5 + 1};
	for(int i = 0; i < n; i++) {
		int u;
		cin >> u;
		if(a.back() != u) {
			a.push_back(u);
		}
	}
	n = a.size();
	dp[0] = 1;
	for(int i = 1; i < n; i++) {
		// cout << a[i] << endl;
		if(ls[a[i]]) {
			dp[i] = dp[i - 1] + dp[ls[a[i]] - 1];
		} else {
			dp[i] = dp[i - 1];
		}
		ls[a[i]] = i + 1;
		dp[i] %= mod;
	}
	cout << dp[n - 1];
    return 0;
}

Measured memory_bytes: 3956
#include <stdio.h>
 
int main()
{
    int i;
    int a[6];
    int tmp;
    int o;
    for(i=0; i<6; i++)scanf("%d ", &a[i]);
    while((o=getchar())!='\n'){
        switch(o){
            case 'E':
                tmp=a[0];a[0]=a[3];a[3]=a[5];a[5]=a[2];a[2]=tmp;
                break;
            case 'N':
                tmp=a[0];a[0]=a[1];a[1]=a[5];a[5]=a[4];a[4]=tmp;
                break;
            case 'S':
                tmp=a[0];a[0]=a[4];a[4]=a[5];a[5]=a[1];a[1]=tmp;
                break;
            case 'W':
                tmp=a[0];a[0]=a[2];a[2]=a[5];a[5]=a[3];a[3]=tmp;
                break;
            default:break;
        }
    }
    printf("%d\n", a[0]);
    return 0;
}

Measured memory_bytes: 2748
#include<stdio.h>
int main(void)
{
	int n,x,y,b,p,i,j,a[365];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&x,&y,&b,&p);
		if(b>=5&&p<=2){
			if(x*b+y*p>(x*b+y*2)*0.8){
				a[i]=(x*b+y*2)*0.8;
			}
			else {
				a[i]=x*b+y*p;
			}
		}
		if(b<=5&&p>=2){
			if(x*b+y*p>(x*5+y*p)*0.8){
				a[i]=(x*5+y*p)*0.8;
			}
			else {
				a[i]=x*b+y*p;
			}
		}
		if(b<=5&&p<=2){
			if(x*b+y*p>(x*5+y*2)*0.8){
				a[i]=(x*5+y*2)*0.8;
			}
			else {
				a[i]=x*b+y*p;
			}
		}
		if(b>=5&&p>=2){
			a[i]=(x*b+y*p)*0.8;	
		}
	}
	for(j=0;j<n;j++){
		printf("%d\n",a[j]);
	}
	return 0;
}

Measured memory_bytes: 1032
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<list>
#include<string>
#include<algorithm>
 
using namespace std;

int main() {
  string s;
  cin >> s;
  if(s[2]==s[3]&&s[4]==s[5]){
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;
}


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

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

const int INF=1e9;
const int MOD=1e9+7;

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

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000000000
#define MAXN        300005
#define mod         998244353  
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i;
    cin>>n;
    ll a[n+1],b[n+1],c[n+1];
    for(i=1;i<=n;i++){
        cin>>a[i];
        b[i]=i+a[i];
        c[i]=i-a[i];
    }
    map<ll,ll> mp1;
    ll ans=0;
    for(i=1;i<=n;i++){
        mp1[b[i]]++;
        ans+=mp1[c[i]];
    }
    cout<<ans;
}

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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==5 && b==5 && c==7)|| (a==5 && b==7 && c==5) || (a==7 && b==5 && c==5))
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
    return 0;
}


Measured memory_bytes: 3564
#include <stdio.h>
int main()
{
 int a,b,s,r;
 double f;
 scanf("%d%d",&a,&b);
 s=a/b;
 r=a%b;
 f=(double)a/b;
 printf("%d %d %f\n",s,r,f);
 return 0;
}



Measured memory_bytes: 2104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }
    struct SS
    {
        public int X, Y;
        public SS(int x, int y)
        {
            X = x;
            Y = y;
        }
    }

    class Program
    {
        private int N;
        private string[] S;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            S = sc.Array();
        }

        public void Solve()
        {
            Scan();
            var a = new int[200];
            foreach(var s in S)
            {
                a[s[0]]++;
            }
            var aaa = new char[] { 'P', 'W', 'G', 'Y' };
            int cnt = 0;
            foreach(var c in aaa)
            {
                if (a[c] > 0)
                    cnt++;
            }
            if(cnt==3)
            {
                Console.WriteLine("Three");
            }
            if(cnt==4)
            {
                Console.WriteLine("Four");
            }
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <iostream>
#include <cctype>
using namespace std;

int main(){
    while(1){
        char ch;
        scanf("%c",&ch);
        
        if(ch == '\n') break;
        
        if(islower(ch)) ch = toupper(ch);
        else if(isupper(ch)) ch = tolower(ch);
        
        printf("%c",ch);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3148
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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")
    };
}

pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        k: u64
    }
    let k = k + 1;
    let mut sum = 0;
    for a in 1..k {
        for b in 1..k {
            let g = gcd(a,b);
            for c in 1..k {
                sum += gcd(g, c);
            }
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 2136
h,w=map(int,input().split())
M=[list(input()) for i in range(h)]
D=[[0]*w for i in range(h)]
U=[[0]*w for i in range(h)]
R=[[0]*w for i in range(h)]
L=[[0]*w for i in range(h)]

for i in range(h):
    c=0
    for j in range(w):
        if M[i][j]=='.':
            c+=1
            R[i][j]=c
        else:
            c=0
for i in range(h):
    c=0
    for j in range(w):
        if M[i][w-1-j]=='.':
            c+=1
            L[i][w-1-j]=c
        else:
            c=0
for j in range(w):
    c=0
    for i in range(h):
        if M[i][j]=='.':
            c+=1
            D[i][j]=c
        else:
            c=0
for j in range(w):
    c=0
    for i in range(h):
        if M[h-1-i][j]=='.':
            c+=1
            U[h-1-i][j]=c
        else:
            c=0
r=0
for i in range(h):
    for j in range(w):
        r=max(r,R[i][j]+L[i][j]+D[i][j]+U[i][j]-3)
print(r)

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

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

  int ans = 0;
  rep(i, S.length()) {
    if (S[i] != T[i]) ans++;
  }
  cout << ans;
}

Measured memory_bytes: 3824
#include<stdio.h>

int main(void){
	int a, b;
	char op;
	
	for(;;){
		scanf("%d %c %d", &a, &op, &b);
		if(op == '?'){
			break;
		}else if(op == '+'){
			printf("%d\n", a+b);
		}else if(op == '-'){
			printf("%d\n", a-b);
		}else if(op == '*'){
			printf("%d\n", a*b);
		}else if(op == '/'){
			printf("%d\n", a/b);
		}else{
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc139_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int[] box = new int[N];

            for (int i = 0; i < N; i++)
            {
                box[i] = Convert.ToInt32(input[i]);
            }
            int max = 0;
            int cnt = 0;

            for (int i = 0; i < box.Length - 1; i++)
            {
                if (box[i] >= box[i + 1])
                {
                    cnt++;
                    if (max <= cnt)
                    {
                        max = cnt;
                    }
                }
                else
                {
                    cnt = 0;
                }
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 26972
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

##############################
n,m = map(int,input().split()) #n:頂点数  w:辺の数
lst=[]

d = [[float("inf")]*n for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(m):
    x,y,z = map(int,input().split())
    x-=1
    y-=1
    d[x][y] = z
    d[y][x] = z
    lst.append([x,y,z])
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０

table=warshall_floyd(d)
ans=0

for x,y,z in lst:
    if table[x][y]!=z:
        ans+=1


print(ans)

Measured memory_bytes: 74436
def main():
    a, b, c, d = map(int, input().split())

    for i in range(10000):
        if c <= 0:
            print('Yes')
            exit()
        if a <= 0:
            print('No')
            exit()
        if i % 2 == 0:
            c -= b
        else:
            a -= d

if __name__ == '__main__':
    main()

Measured memory_bytes: 61680
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int a) {
	if (a < 0) {
		return -a;
	}
	return a;
}

long long N, M,  K, W,L,A[100], ans, k[5],B,C,n[2];
string s, t[100];
bool a, b, c;
int main() {
	cin >> N>>M>>K;
	B = C = 0;
	for (int i = 0; i < M; i++) {
		cin >> A[i];
		if (A[i] < K) {
			B++;
		}
		if (A[i] > K) {
			C++;
		}
	}

		cout << Lmin(B,C) << endl;
	
	return 0;
}




Measured memory_bytes: 256
N,M=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(M)]
s=[sc[i][0] for i in range(M)]
c=[sc[i][1] for i in range(M)]

for i in range(1000):
    if len(str(i)) == N:
        for j in range(M):
            if str(i)[s[j]-1] != str(c[j]):
                break
        else:
            print(i)
            break
else:
    print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll X, Y;
    cin >> X >> Y;
    double x=-0.5*Y+2*X;
    double y=0.5*Y-X;
    if(fmod(x,1)==0 && fmod(y,1)==0 && x>=0 && y>=0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3760
// Problem : A - Air Conditioner
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define pvar(x) clog<<"["<<#x<<":"<<x<<"]\n"
using namespace std;
using ll = long long int;
void solve(){
	int n;
	cin>>n;
	if(n >= 30)cout<<"Yes\n";
	else cout<<"No\n";
}
int main(){
	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  while(t--){
		solve();
	}
}
 


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n, k;
    cin >> n >> k;
    unordered_map<ll, ll> count;
    for(int i = 0; i < n; ++i){
        ll a;
        cin >> a;
        count[a]++;
    }
    vector<ll> a;
    for(auto it = count.begin(); it != count.end(); ++it){
        a.push_back(it->first);
    }
    sort(a.begin(), a.end(), [count](ll x, ll y){
        return count.at(x) < count.at(y);
    });
    ll ans = 0;
    for(int i = 0; i < (ll)a.size() - k; ++i){
        ans += count.at(a.at(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23800
MAX = 3*10**5+100
MOD = 998244353
fact = [0]*MAX #fact[i]: i!
inv = [0]*MAX #inv[i]: iの逆元
finv = [0]*MAX #finv[i]: i!の逆元
fact[0] = 1
fact[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
    
for i in range(2, MAX):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD

def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

N, A, B, K = map(int, input().split())
ans = 0

for i in range(N+1):
    if (K-A*i)%B==0:
        j = (K-A*i)//B
        ans += C(N, i)*C(N, j)
        ans %= MOD

print(ans)

Measured memory_bytes: 87640
def main():
    N = int(input())
    A = map(int, input().split())

    d = {}
    ans = 0
    for i, a in enumerate(A, 1):
        x, y = min(i, a), max(i, a)
        d[(x, y)] = d.get((x, y), 0) + 1
        if d[(x, y)] == 2:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 30572
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 1e5 + 10;
pair<ll, ll> a[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;
    for (int i=1; i<=n; i++) {
        ll x, l;
        cin >> x >> l;
        a[i].S = x - l;
        a[i].F = x + l;
    }
    sort(a + 1, a + n + 1);
    for (int i=1; i<=n; i++) {
        swap(a[i].F, a[i].S);
    }
    int ans = 0;
    ll mx = -1e18;
    for (int i=1; i<=n; i++) {
        if (a[i].F >= mx) {
            ans++;
            mx = a[i].S;
        }
    }
    cout << ans << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
   return 0;
}


Measured memory_bytes: 1792
N,K = map(int,input().split())
D = [str(i) for i in input().split()]

#print(D)
#print(list(str(N)))

while 1:
    check = True
    for i in D:
        if i in list(str(N)):
            check = False
            break
    if check:
        break
    
    N += 1

print(N)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

typedef struct UnionFindTree{
  vector<int> par;
  vector<int> treerank;
  
  UnionFindTree(int n){
    par.resize(n); treerank.resize(n);
    rep(i, n) par[i] = i, treerank[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(treerank[x] < treerank[y]) swap(x, y);
    if(treerank[x] == treerank[y]) treerank[x]++;
    par[y] = x;
    return;
  }
  
  bool same(int x, int y){
    return find(x) == find(y);
  }
}UF;

int main(){
    int n, m; cin >> n >> m;
    UF uf(n);
    rep(i, m){
        int x, y, z;
        cin >> x >> y >> z;
        uf.unite(x-1, y-1);
    }
    vector<bool> used(n, false);
    int cnt = 0;
    rep(i, n)if(!used[uf.find(i)]){
        used[uf.find(i)] = true;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in)) {
			double w = sc.nextInt();
			double h = sc.nextInt();
			double x = sc.nextInt();
			double y = sc.nextInt();
			
			double area = w * h / 2;
			boolean check = false;
			
			if (w / 2 == x && h / 2 == y) {
				check = true;
			}
			
			if (check) {
				System.out.println(area + " " + 1);
			} else {
				System.out.println(area + " " + 0);
			}
		}

	}

}


Measured memory_bytes: 23252