akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    string s;
    string ans = "";
    cin >> s;
    int n = s.size();
    rep(i, n){
        if (s[i] == '0') ans += '0';
        else if (s[i] == '1') ans += '1';
        else if (s[i] == 'B'){
            if (ans.size() > 0) ans = ans.erase(ans.size() - 1);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
    {
       char s;
       cin >> s;

       if (isupper(s))
       {
           cout << "A" << endl;
       }
       else
       {
           cout << "a" << endl;
       }

       return 0;
}

Measured memory_bytes: 3628
from collections import defaultdict
n = int(input())

dct = defaultdict(list)
score = []
for i in range(1,n+1):
    s,p = map(str,input().split())
    dct[s].append(int(p))
    score.append(int(p))

for key in dct.keys():
    dct[key].sort()
    dct[key].reverse()
dct = sorted(dct.items())

for store in dct:
    for p in store[1]:
        print(score.index(p)+1)

Measured memory_bytes: 3316
n = int(input())
ls = [0]*n
param_list = [0]*2**n
for i in range(2**n):
    l = [False]*n
    for id_r, row in enumerate(ls):
        if i & (2 ** id_r) >0:
            l[id_r] = True
    param_list[i] = l 


for i in range(n):
    A = int(input())
    for k in range(A):
        a,b = map(int, input().split())
        b = (1==b)
        new_param =[]
        for d in param_list:
            if d[i]:
                if d[a-1] == b:
                    new_param.append(d)
                    pass
                else:
                    #print(2)
                    pass
            else:
                new_param.append(d)
                #if d[a-1] is b:
                    #print(3)
                    #pass
                #else:
                    #print(4)
                    #new_param.append(d)
                    #pass
            
        param_list = new_param
        #print(param_list)
            
ans = 0    
for d in param_list:
    ans = max(ans, d.count(True))
print(ans)

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

const int MAX_N = 13, INF = 0x3f3f3f3f;
int N, M;
struct Key
{
	int cost;
	vector<int> door;
}Keys[1006];

int dp[1<<MAX_N];

void solve()
{
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for(int i=0;i<(1<<N);++i)for(int j=0;j<M;++j){
			int nex = i;
			for(int k=0;k<Keys[j].door.size();++k) nex |= (1<<(Keys[j].door[k]));
			dp[nex] = min(dp[nex], dp[i]+Keys[j].cost);
	}
	if(dp[(1<<N)-1]==INF) cout << -1 << "\n";
	else cout << dp[(1<<N)-1] << "\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> M;
	int b,c;
	for(int i=0;i<M;++i){
		cin >> Keys[i].cost >> b;
		while(b--){
			cin >> c;
			Keys[i].door.push_back(c-1);
		}
	}
	solve();
	return 0;
}

Measured memory_bytes: 384
def main():
    n = int(input())
    t = tuple(map(int, input().split()))
    total = sum(t)
    m = int(input())
    px = [tuple(map(int, input().split())) for _ in range(m)]
    for (p, x) in px:
        print(total - t[p - 1] + x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  ll n,k;
  cin>>n>>k;
  vecint a(n);
  REP(i,n)cin>>a[i];
  vecint nxt(n);
  vecint old(200001, -1);
  REP(i,n) {
    if (old[a[i]] >= 0) {
      nxt[old[a[i]]] = i+1;
    }
    old[a[i]] = i;
  }
  REP(i,n) {
    if (old[a[i]] >= i) {
      nxt[old[a[i]]] = i+1+n;
    }
    old[a[i]] = i;
  }
  vecint step(n);
  for (int i=n-1; i>=0; --i) {
    if (nxt[i] >= n) {
      step[i] = nxt[i]-n;
    } else {
      step[i] = step[nxt[i]];
    }
  }
  int init_len = 0;
  int loop_size = 0;
  int index = 0;
  int count = 0;
  map<int, int> idxmap;
  idxmap[0] = 0;
  while (1) {
    ++count;
    index = step[index];
    //cerr<<index<<endl;
    if (idxmap.count(index)) {
      init_len = idxmap[index];
      loop_size = count - init_len;
      break;
    } else {
      idxmap[index] = count;
    }
  }
  map<int, int> revmap;
  for (auto p : idxmap) {
    revmap[p.second] = p.first;
  }
  int idx = 0;
  --k;
  if (k >= init_len) {
    k -= init_len;
    k %= loop_size;
    k += init_len;
  }
  idx = revmap[k];
  //for (auto p : idxmap) {
  //  cerr<<p.first<<' '<<p.second<<endl;
  //}
  //cerr<<idx<<endl;
  vecint s;
  while (idx < n) {
    if (nxt[idx] <= n) {
      idx = nxt[idx];
    } else {
      s.push_back(a[idx]);
      ++idx;
    }
  }
  int l = s.size();
  REP(i,l) {
    if(i) cout<<' ';
    cout<<s[i];
  }
  cout<<endl;
  return 0;
}


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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    int A,B,C,D; cin >> A>>B>>C>>D;
    
    cout << min(A,B)+min(C,D) << endl;
}


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

int main() {
    int n;
    scanf("%d",&n);
    pair<int,int> p[n];
	int x,l;
    for(int i=0;i<n;i++){
        scanf("%d%d",&x,&l);
		p[i].first=x+l; //exclusive
		p[i].second=x-l+1; //inclusive
    }
    sort(p,p+n);
    int ans=0,t=-2000000000;
    for(int i=0;i<n;i++){
        if(p[i].second>t){
            t=p[i].first;
            ans++;
        }
    }
    printf("%d",ans);
}

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

int main() {
	int n;
	cin >> n;
	vector<int> value(n);
	for (int i = 0; i < n; i++)cin >> value.at(i);
	vector<int> cost(n);
	for (int i = 0; i < n; i++)cin >> cost.at(i);
	vector<int> interest(n);
	for (int i = 0; i < n; i++)interest.at(i) = value.at(i) - cost.at(i);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (interest.at(i) > 0)ans += interest.at(i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<string>vec(N);
  set<string>se;
  for(int X=0; X<N; X++){
    cin >> vec.at(X);
    se.insert(vec.at(X));
  }
  cout << se.size() << endl;
}

Measured memory_bytes: 25064
#include <stdio.h>

int main() {
    int sum=0;
    char ch;
    
    while(true){
        while((ch=getchar()) != '\n'){
            sum += ch - '0';
        }
        if(sum==0)
        break;
        else{
            printf("%d\n",sum);
            sum=0;
        }
    }
    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


signed main(void){
    int N,a;
    vector<int> A;
    cin >> N;
    bool z = false;
    REP(i,N){
        cin >> a;
        A.push_back(a);
        if(a==0)z=true;
    }
    const int sup = 1000000000000000000;
    int Ans=1;
    bool dam = false;
    REP(i,N){
        if(A[i]==0 || Ans<=2*sup/A[i]){
            Ans*=A[i];
        }else{
            dam=true;
        }
        //cout << Ans << endl;
    }
    if(Ans>sup)dam=true;
    
    if(dam && !z){
        cout << -1 << endl;
    }else{
        cout << Ans << endl;
    }
    
    return 0;
}




Measured memory_bytes: 4320
import numpy as np
 
N,M = map(int,input().split()) 
 
AC = np.array([0]*N)
WA = np.array([0]*N)
 
for i in range(M):
    p,S = input().split()
    
    if AC[int(p)-1] ==0 and S == "WA":
       WA[int(p)-1] += 1
    else:
        AC[int(p)-1] = 1

print(sum(AC),sum(AC*WA))

Measured memory_bytes: 21024
S = gets.chomp.split("").map(&:to_i)
N = S.size
ans = 0
#p S,N
S.each_with_index{ |a,k|
  rightgaps = N-k-1
  #p [a,k,rightgaps]
  d = 1
  (0...N-k).each{ |x|
    t = (1 << ( [rightgaps - (1+x), 0].max + k ))
    #p [x,d,t]
    ans += a * d * t
    d *= 10
  }
  #p ans
}
p ans

Measured memory_bytes: 1788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args){
		int[] abo = {0,0,0,0};
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp = null;
		int cup = 0;
		int mun = 0;
		int ter = 0;
		String[] rrr;
		int st = 0,sr = 0;
		int mon = 0;
		int syo=0,hisi=0;
		long aaaa = 1;
		
		
		//while(true){
			
			try {
				tmp = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			
//			if(tmp == null){
//				break;
//			}
//			
//			if(tmp.equals("")){
//				break;
//			}
			
			mon = Integer.parseInt(tmp);
			
			
			for(int i=1;i<mon+1;i++){
				aaaa = aaaa*i;
			}
			
			System.out.println(aaaa);
			
		//}
	}

}

Measured memory_bytes: 17032
D,N = map(int,input().split())
ans = 0

if D == 0 and N !=100:
  print(N)
  
elif D == 0 and N == 100:
  print(101)
  
elif D == 1 and N !=100:
  print(N*100)
  
elif D == 1 and N == 100:
  print(10100)
  
elif D == 2 and N != 100:
  print(N*10000)
  
else:
  print(1010000)

Measured memory_bytes: 8984
#include <vector>
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<long long> C(N+1);
  for(int i = 0; i < N; ++i) cin >> A[i], ++C[A[i]];
  long long a = 0;
  for(auto c : C)
    a += c*(c-1)/2;
  for(int i = 0; i < N; ++i){
    long long a_ = a - C[A[i]] + 1;
    cout << a_ << "\n";
  }
}


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

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static long Calc(int n, int p, int[] xs) {
        var dp = new long[100 * n + 1];

        for (int i = 0; i < xs.Length; i++) {
            int x = xs[i];
            for (int j = dp.Length - x - 1; j > 0; j--) {
                dp[j + x] += dp[j];
            }
            dp[x]++;
        }

        long ans = (p == 0) ? 1 : 0;
        int s = p == 0 ? 0 : 1;
        for (int i = s; i < dp.Length; i += 2)
            ans += dp[i];
        return ans;
    }

    static void Main() {
        var np = ReadInts();
        int n = np[0], p = np[1];
        var xs = ReadInts();

        Console.WriteLine(Calc(n, p, xs));
    }
}

Measured memory_bytes: 13360
*I,M=r=j=x=1,10**9+7;`sed 1d`.split.map{|k|x=$*[k=k.to_i]||x+1;$*[k]=$.+=1}.map{|i|I<<s=i<2?1:M/i*-I[M%i];p (-j+r=r*($.+1-i)*s%M)%M;j=j*(x-i)*s%M}

Measured memory_bytes: 19508
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

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

template<typename T>
void dijkstra(const vector< vector<edge> >& G, vector<T>& d, int s)
{
   priority_queue<P<T,int>, vector<P<T,int>>, greater<P<T,int>> > que;
   fill(d.begin(), d.end(), INF);
   d[s] = 0;
   que.push(make_pair(0, s));
   while(!que.empty()) {
      T temp_cost = que.top().first;
      int from = que.top().second;
      que.pop();
      if (d[from] < temp_cost) continue;
      for (int i = 0; i < G[from].size(); i++) {
         edge e = G[from][i];
         if (d[e.to] > d[from] + e.cost) {
            d[e.to] = d[from] + e.cost;
            que.push(make_pair(d[e.to], e.to));
         }
      }
   }
}

void add_edge(V<V<edge>>& G, int u, int v, int cost) {
   if (u == v) return;
   G[u].push_back((edge){ v, cost });
}

signed main()
{
   int K; cin >> K;
   V<V<edge>> G(K);
   for (int i = 0; i < K; i++) {
      add_edge(G, i, (i+1)%K, 1);
   }
   for (int i = 0; i < K; i++) {
      add_edge(G, i, (i*10)%K, 0);
   }

   V<int> d(K);
   dijkstra(G, d, 1);
   int ans = d[0] + 1;
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	int n; cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	ll cur = 0;
	for (int i = 0; i < n; i++) {
		cur = a[i] - cur;
	}
	vector<ll> ans(n);
	ans[0] = cur / 2;
	for (int i = 1; i < n; i++) {
		ans[i] = a[i - 1] - ans[i - 1];
	}
	for (int i = 0; i < n; i++) cout << 2LL * ans[i] << " \n"[i == n - 1];
	return 0;
}

Measured memory_bytes: 2944
s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
s = s.split(", ")
k = int(input())
print(s[k-1])

Measured memory_bytes: 2940
#include<stdio.h>

double z(double a){
  if(a>0)return a;
  else return -a;
}

int main(void){
  int i;
  int N;
  double T,A;
  
  scanf("%d\n",&N);
  scanf("%lf %lf",&T,&A);
  
  int h[N+1];
  
  for(i=0;i<N;i++){
    scanf("%d",&h[i]);
  }
  
  double m=z(A-T+h[0]*0.006);
  int ans=0;
  
  for(i=1;i<N;i++){
    if(m>z(A-T+h[i]*0.006)){
      m=z(A-T+h[i]*0.006);
      ans=i;
    }
    else{}
  }
  
  printf("%d\n",ans+1);
  
  return 0;
}
   
       

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

int main(){
  int N; cin>>N;
  map<int,int> mp, mp2;
  for(int i=0;i<N/2;i++){
    int a,b; cin>>a>>b;
    mp[a]++, mp2[b]++;
  }
  int ev = 0, ov = 0, E = 0, O = 0;
  for(auto &p:mp){
    if(E < p.second){
      ev = p.first;
      E = p.second;
    }
  }
  for(auto &p:mp2){
    if(O < p.second){
      ov = p.first;
      O = p.second;
    }
  }
  int ans = 0;
  if(ev != ov)
    ans = N - E - O;
  else{
    int E2 = 0, O2 = 0;
    for(auto &u:mp)
      if(E2 < u.second && ev != u.first) E2 = u.second;
    for(auto &u:mp2)
      if(O2 < u.second && ov != u.first) O2 = u.second;
    ans = min(N - E2 - O, N - E - O2);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n,k;
	vector<int>v;
	cin >> n >> k;
	for (size_t i = 0; i < n; i++)
	{
		int hoge;
		cin >> hoge;
		v.emplace_back(hoge);
	}
	sort(v.begin(), v.end());
	int ans=0;
	for (size_t i = 0; i < k; i++)
	{
		ans += v[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
n, y = map(int, input().split())
for i in range(n+1):
	for j in range(n+1):
		k = n-(i+j)
		if k < 0:
			continue
		s = i*10000+j*5000+k*1000
		if s == y:
			print (i,j,k)
			exit()
print (-1,-1,-1)

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  string s, t;
  cin >> s >> t;

  bool ok = true;
  for (ll i = 0; i < s.size(); ++i) {
    if (s[i] != t[i]) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;


#define MAX_N 1005

int N,MA,MB;

int dp[45][405][405];

struct ST{
	int a,b,c;
}s[45];

int main(){
	cin>>N>>MA>>MB;

	for(int i=1;i<=N;++i){
		cin>>s[i].a>>s[i].b>>s[i].c;
	}

	for(int k=0;k<=N;++k){
	for(int i=0;i<=400;++i){
		for(int j=0;j<=400;++j){
			dp[k][i][j]=5000;
		}
	}
	}

	dp[0][0][0]=0;

	for(int i=1;i<=N;++i){
		for(int A=0;A<=400;++A){
			for(int B=0;B<=400;++B){
				if(A>=s[i].a && B>=s[i].b){
					dp[i][A][B]=min(dp[i-1][A-s[i].a][B-s[i].b]+s[i].c,dp[i-1][A][B]);
				}
				else dp[i][A][B]=dp[i-1][A][B];
			}
		}
	}
	int ans=5000;
	for(int A=1;A<=400;++A){
		for(int B=1;B<=400;++B){
			if(dp[N][A][B]<5000 && A*MB==B*MA){
				ans=min(ans,dp[N][A][B]);
			}
		}
	}
	if(ans==5000)puts("-1");
	else printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int a,b;
	cin>>a>>b;
	int ans = 0;
	for(int i=a; i<=b; i++){
		string tmp = to_string(i);
		bool ok=true;
		for(int j=0; j<tmp.size()/2; j++){
			if(tmp[j]!=tmp[tmp.size()-j-1]){
				ok=false;
			}
		}
		if(ok) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string S; int N; long long t, sum, ans;
int main() {
  cin >> S; N = S.size();
  for(int i = 0; i < (1<<N-1); ++i) {
    t = S[0]-'0'; sum = 0;
    for(int j = 1; j < N; ++j) {
      if(i & (1<<j-1)) sum += t, t = 0;
      t = t*10 + (S[j]-'0');
    }
    ans += t+sum;
  }
  cout << ans;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

mod = 10**9 + 7

def inv(x):
    return pow(x, mod - 2, mod)

def comb(n, k):
    res = 1
    for i in range(k):
        res = (res * (n - i) * inv(i + 1)) % mod
    return res

H, W, A, B = map(int, input().split())

c1 = comb(H - A - 1 + B, B)
c2 = comb(A - 1 + W - B - 1, W - B - 1)
ans = 0
for i in range(B + 1, W + 1):
    ans = (ans + c1 * c2) % mod
    c1 = (c1 * (H - A - 1 + i) * inv(i)) % mod
    c2 = (c2 * (W - i) * inv(A - 1 + W - i)) % mod
print(ans)


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

using namespace std;

int main(void){
  string str;
  int count = 0;
  
  cin >> str;
  
  for(int i = 0 ; i < str.length() ; i++){
    if(str[i] == '1') count++;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N;
    cin >> N;
    ll x[N];
    for(ll i = 0; i < N; i++) cin >> x[i];
    ll oidx = 1, eidx = 0;
    for(ll i = 0; i < N; i++){
        if(i & 1) if(x[oidx] < x[i]) oidx = i;
        if(!(i & 1)) if(x[eidx] < x[i]) eidx = i;
    }
    vector<ll> odd, even;
    ll osum = 0, esum = 0;
    for(ll i = 0; i < N; i++){
        if(i & 1){
            if(i == oidx || x[i] > 0){
                odd.push_back(i);
                osum += x[i];
            }
        }else{
            if(i == eidx || x[i] > 0){
                even.push_back(i);
                esum += x[i];
            }
        }
    }
    cout << max(osum, esum) << endl;
    vector<ll> v = (osum > esum ? odd : even);
    vector<ll> ans;
    ll idx = 0;
    ll rest = N;
    for(ll i = 0; i < N; i++){
        if(idx == 0 && i < v[idx]){
            ans.push_back(1);
            rest--;
        }else{
            if(idx == v.size() - 1){
                for(ll j = rest; j > 1; j--) ans.push_back(j);
                break;
            }else{
                ll between = v[idx + 1] - v[idx];
                while(between > 2){
                    ans.push_back(3);
                    rest -= 2;
                    between -= 2;
                }
                ans.push_back(2);
                rest -= 2;
                idx++;
            }
        }
    }
    cout << ans.size() << endl;
    for(auto u : ans) cout << u << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
    public static void main(String[] args) throws IOException {
       Scanner in = new Scanner(System.in);
       int d;
       int idx = 0;
       while((d = in.nextInt()) != 0) {
	       System.out.printf("Case %d: %d\n", ++idx, d);
       }
    }
}

Measured memory_bytes: 53392
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	std::string s, w; cin >> s >> w;
	
	std::string ans = std::string(55, 'z');
	for(int i = 0; i < s.size() - w.size() + 1; i++){
		bool f = true;
		for(int j = 0; j < w.size(); j++){
			if(s[i + j] == '?') continue;
			if(s[i + j] != w[j]) f = false;
		}
		if(!f) continue;
		
		std::string A = s;
		for(int j = 0; j < w.size(); j++){
			A[i + j] = w[j];
		}
		
		for(int j = 0; j < s.size(); j++){
			if(A[j] == '?') A[j] = 'a';
		}
		
		ans = std::min(ans, A);
	}
	
	if(ans == std::string(55, 'z')) cout << "UNRESTORABLE" << endl;
	else cout << ans << endl;
	return 0;
}


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

int main(){
    int a[100],b[100],n;
    double A,B,C,D=0;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];  
    for(int i=0;i<n;i++){
        A+=fabs(a[i]-b[i]);
        B+=pow((a[i]-b[i]),2);
        C+=pow(fabs(a[i]-b[i]),3);
        D=D<fabs(a[i]-b[i])?fabs(a[i]-b[i]):D;
    }
    printf("%lf\n%lf\n%lf\n%lf\n",A,sqrt(B),pow(C,1/3.0),D);
    return 0;
}


Measured memory_bytes: 3356
import java.util.*;
import java.io.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		System.out.println((x / 3600) + ":" + (x % 3600 / 60) + ":" + (x % 60));
	}
}



Measured memory_bytes: 26344
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int num[100050];

void read(int &a)
{
    a = 0;
    char c = getchar();
    while (c < '0' || c > '9')
        c = getchar();
    while (c >= '0' && c <= '9')
    {
        a *= 10;
        a += c - '0';
        c = getchar();
    }
}

int main()
{
    int n, ls, maxx = 0, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        read(ls);
        num[ls]++;
        maxx = max(maxx, ls);
    }
    int j = maxx;
    for (int i = 1; i <= maxx; i++)
    {
        if (num[i] > 1)
        {
            while (num[j] <= 1 && j > i)
                j--;
            if (j > i)
            {
                if (num[i] == num[j])
                {
                    num[i] = 1;
                    num[j] = 1;
                }
                else if (num[i] > num[j])
                {
                    ls = num[j] - 1;
                    num[i] -= ls;
                    num[j] = 1;
                    i--;
                }
                else
                {
                    ls = num[i] - 1;
                    num[j] -= ls;
                    num[i] = 1;
                    j++;
                }
            }
        }
    }
    for (int i = 1; i <= maxx; i++)
    {
        if (num[i] == 1)
            ans++;
        else if (num[i] > 1)
        {
            if (num[i] % 2 == 0)
                continue;
            else
                ans++;
        }
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 640
inpl = lambda: list(map(int,input().split()))
X = int(input())
if X < 100:
    print(0)
    exit()
elif X <= 105:
    print(1)
    exit()
dp = [False]*(X+1)
goods = list(range(100,106))
dp[0] = True
for k in goods:
    dp[k] = True

for i in range(200, X+1):
    for k in goods:
        if dp[i-k]:
            dp[i] = True
            break
if dp[X]:
    print(1)
else:
    print(0)

Measured memory_bytes: 39792
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n,k = map(int, input().split())
a = list(map(int, input().split()))

d = [0]*(n+1)

for i in range(n):
    d[a[i]] += 1

d.sort()

print(sum(d[:n-k+1]))


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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define flood(arr, c, s) for (int i=0; i<s; i++) arr[i] = c
//#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
const int N = 1e5 + 2;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int32_t main() {
    FAST_IO;
    string s;
    cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC");
    return 0;
}

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

int main()
{
	int a, b;
	cin >> a >> b;

	int j = 1;
	if (b == 1 || b == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	if (j * a >= b) 
	{
		cout << j << endl;
		return 0;
	}
	int k = 0;
	do
	{
		j += a - 1;
		k++;
	} while (j < b);
	cout << k << endl;


	return 0;

}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int s, w; cin >> s >> w;
    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;

constexpr int lim = 100000;
char isprime[lim];
int prime[lim];
int ind = 0;

void set_prime() {
    fill(isprime, isprime + lim, 1);
    isprime[0] = isprime[1] = 0;

    for (int x = 2; x < lim; ++x) {
        if (!isprime[x]) continue;
        prime[ind++] = x;

        if (x * 2 >= lim) continue;
        for (int y = x * 2; y <  lim; y += x) {
            isprime[y] = 0;
        }
    }
}

pair<int, int> solve(const int& m, const int& a, const int& b) {
    int max_pq = 0;
    pair<int, int> ret;
    for (int j = 0; j < ind && prime[j] < m; ++j) {
        int q = prime[j];

        int* lb = lower_bound(prime, prime + ind, (double)a * q / b);

        int p = *(upper_bound(prime, prime + ind, min(q, m / q)) - 1);

        if(*lb <= p && p * q > max_pq) {
            max_pq = p * q;

            ret = make_pair(p, q);
        }
    }

    return ret;
}

int main() {
    set_prime();

    int m, a, b;
    while (true) {
        cin >> m;
        cin >> a;
        cin >> b;

        if(m == 0) break;
        pair<int, int> ret = solve(m, a, b);
        cout << ret.first << ' ' << ret.second << endl;
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

ll factorial(ll n) {
  ll ans = 1;
  if (n == 1){
    return 1;
  }
  for (int i = 1; i <= n; i++) {
    ans *= i;
  }
  return ans;
}

int main(void) {
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  if (n >= 2) {
    ans += n * (n - 1) / 2;
  }
  if (m >= 2) {
    ans += m * (m - 1) / 2;
  }
  fin(ans);
  return 0;
}

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;

struct node{
    int id;
    vector<int> left, right;
};

node n[40];
int v;
vector<int> res;

void post_order(vector<int> root, vector<int> target, int start){
    int i = 0;
    while(target[i] != root[start]){
        n[start].left.push_back(target[i]);
        i++;
    }
    if(n[start].left.size() != 0)
        post_order(root, n[start].left, start + 1);
    i++;
    while(i < target.size()){
        n[start].right.push_back(target[i]);
        i++;
    }
    if(n[start].right.size() != 0)
        post_order(root, n[start].right, start + n[start].left.size() + 1);
    res.push_back(root[start]);
}

int main() {
    cin >> v;
    vector<int> pre(v);
    vector<int> in(v);
    int x;
    REP(i, v){
        cin >> x;
        pre[i] = x;
    }
    REP(i, v){
        cin >> x;
        in[i] = x;
    }
    post_order(pre, in, 0);

    REP(i, v){
        if(i != 0)
            cout << " ";
        cout << res[i];
    }
    cout << endl;
    return 0;
}

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

#define lint long long
#define P pair<int, int>


int main() {
    int N, K;
    cin >> N >> K;
    
    int num = 1 + 2 * (K - 1);
    if(num <= N){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

int main()
{
    vector<vector<ll>> a(3,vector<ll>(3));
    REP(i, 3){
        REP(j, 3){
            cin >> a[i][j];
        }
    }
    ll N;
    cin >> N;
    vector<ll> b(N);
    REP(i, N) { cin >> b[i]; }
    REP(k, N){
        REP(i, 3){
            REP(j, 3){
                if (a[i][j] == b[k])a[i][j]=0;
            }
        }
    }
    bool on=false;;
    
    REP(i,3){
        if(a[i][0]+a[i][1]+a[i][2]==0){on=true;break;}
    }
    REP(j,3){
        if(a[0][j]+a[1][j]+a[2][j]==0){on=true;break;}
    }
    if(a[0][0]+a[1][1]+a[2][2]==0) on=true;
    if(a[0][2]+a[1][1]+a[2][0]==0) on=true;
    if(on)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
<?php

$n = (int)trim(fgets(STDIN));
$act_list = [];
for ($i=1; $i <= $n; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$act_list[$i] = [
		'a' => (int)$input[0],
		'b' => (int)$input[1],
		'c' => (int)$input[2],
	];
}

$dp = [];
for ($i=1; $i <= $n; $i++) { 
	$dp[$i] = [
		'a' => 0,
		'b' => 0,
		'c' => 0,
	];
}
$dp[1] = [
	'a' => $act_list[1]['a'],
	'b' => $act_list[1]['b'],
	'c' => $act_list[1]['c'],
];
// i日目にa,b,cをする場合の幸福度最大値
for ($i=2; $i <= $n; $i++) { 
	$dp[$i]['a'] = max($dp[$i-1]['b'] + $act_list[$i]['a'], $dp[$i-1]['c'] + $act_list[$i]['a']);
	$dp[$i]['b'] = max($dp[$i-1]['a'] + $act_list[$i]['b'], $dp[$i-1]['c'] + $act_list[$i]['b']);
	$dp[$i]['c'] = max($dp[$i-1]['a'] + $act_list[$i]['c'], $dp[$i-1]['b'] + $act_list[$i]['c']);
}

echo max($dp[$n]['a'], $dp[$n]['b'], $dp[$n]['c']);

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

typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9+10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair

int read() {
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}

int a,b;
double x;

int main() {
	a=read();
	b=read();
	x=(double)a/(double)b;
	printf("%.10f",x);
	return 0;
}

Measured memory_bytes: 256
import math
MOD=1000000007
    
def prime(n):
    max=int(math.sqrt(n))
    li=[i for i in range(2,n+1)]
    primes=[]
    while li[0]<=max:
        primes.append(li[0])
        tmp=li[0]
        li=[i for i in li if i%tmp!=0]
    primes.extend(li)
    return primes

sosu=prime(1000)
N=int(input())
Nbeki=1
for i in range(1,N+1):
    Nbeki=Nbeki*i%MOD

soin=[0]*1000

for i in range(1,N+1):
    for j in range(len(sosu)):
        while(i%sosu[j]==0):
            i//=sosu[j]
            soin[sosu[j]]+=1

ans=1
for i in range(len(soin)):
    if(soin[i]!=0):
        ans=ans*(soin[i]+1)%MOD
print(ans)

Measured memory_bytes: 3064
process.stdin.resume();
process.stdin.setEncoding("utf8");

// 標準入力取込
let gInput = "";
process.stdin.on("data", (chunk) => gInput += chunk);
process.stdin.on("end", () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {

    // 整数の数
    const money: number = Number(inputs[0]);

    return console.log((Math.floor(money / 500) * 1000)
                      + (Math.floor((money % 500) / 5) * 5));
}


Measured memory_bytes: 7500
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x_y_c = [list(map(int, input().split())) for i in range(M)]

cost_min = min(a) + min(b)
for i in range(M):
    x, y, c = x_y_c[i]
    cost = a[x-1] + b[y-1] - c
    cost_min = min(cost_min, cost)
print(cost_min)

Measured memory_bytes: 38492
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int n, m, c;
    cin >> n >> m >> c;
    vector<int>bm(m);
    for(int i = 0; i < m; i++){
        cin >> bm.at(i);
    }
    vector<vector<int> >anm(n, vector<int>(m));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> anm.at(i).at(j);
        }
    }
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int tmp = c;
        for(int j = 0; j < m; j++){
            tmp += (anm.at(i).at(j) * bm.at(j));
        }
        if(tmp > 0){
            cnt++;
        }
    }
    cout << cnt << endl;
    solve();
    return 0;
}



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

int main(){
  ll a, b, k;
  cin >> a >> b >> k;

  if(k>=a){
    if((k-a)>=b){
      cout << 0 << " " << 0 << endl;
    }
    else{
      cout << 0 << " " << b-(k-a) << endl;
    }
  }
  else{
      cout << a-k << " " << b << endl;
  }

  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <typename T>
struct edge {
    int from, to; T cost;
    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template <typename T>
vector<T> dijkstra(int s,vector<vector<edge<T>>> &G){
    size_t n=G.size();
    vector<T> d(n, INF<T>);
    priority_queue<pair<T, int>,vector<pair<T, int>>,greater<>> Q;
    d[s]=0;
    Q.emplace(0,s);
    while(!Q.empty()){
        T cost; int i;
        tie(cost, i) = Q.top(); Q.pop();
        if(d[i] < cost) continue;
        for (auto &&e : G[i]) {
            auto cost2 = cost + e.cost;
            if(d[e.to] <= cost2) continue;
            d[e.to] = cost2;
            Q.emplace(d[e.to], e.to);
        }
    }
    return d;
}

int main() {
    int n, m, l;
    while(cin >> n >> m >> l, n){
        vector<vector<edge<int>>> G(n*(l+1));
        auto f = [&n, &l](int i, int j){return i*(l+1)+j; };
        for (int i = 0; i < m; ++i) {
            int a, b, d, e;
            cin >> a >> b >> d >> e;
            a--; b--;
            for (int j = 0; j <= l; ++j) {
                G[f(a, j)].emplace_back(f(b, j), e);
                G[f(b, j)].emplace_back(f(a, j), e);
                if(j >= d){
                    G[f(a, j)].emplace_back(f(b, j-d), 0);
                    G[f(b, j)].emplace_back(f(a, j-d), 0);
                }
            }
        }
        int ans = INF<int>;
        auto d = dijkstra(f(0, l), G);
        for (int i = 0; i <= l; ++i) {
            ans = min(ans, d[f(n-1, i)]);
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 11352
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int N;
ll h[100000];

void solve()
{
    int a[100000] = {0};
    REPR(i, N-2){
        if(h[i] >= h[i+1]) a[i] = a[i+1] + 1;
        else a[i] = 0;
    }

    int ans = 0;
    REP(i, N) ans = max(ans, a[i]);
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> h[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] P = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                P[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(N, P);
    }
}

class Solver {
    public void solve(long N, long[] P) {
        long ans = 0;
        long min = Long.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            if (min > P[i]) {
                ans++;
                min = P[i];
            }
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 81224
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
                string nm = Console.ReadLine();
                string[] nmin = nm.Split(' ');
                int n = int.Parse(nmin[0]);
                int m = int.Parse(nmin[1]);
                int[,] a = new int[n,m];
                int[] b = new int[m];
                int[] answer = new int[n];

                for (int row = 0; row < n; row++)//a???????¬???????????????\???????????????????????£??\
                {
                    string input1 = Console.ReadLine();
                    string[] inputa = input1.Split(' ');

                    for(int col = 0; col < m; col++)
                    { 
                        a[row,col] = int.Parse(inputa[col]);
                    }
                }

                for (int i = 0; i < m; i++)
                {
                    string input2 = Console.ReadLine();
                    b[i] = int.Parse(input2);               
                }


                for (int row = 0; row < n; row++)//?¨??????????????????????????????\??????
                {
                    for (int col = 0; col < m; col++)
                    {
                        answer[row] = answer[row] + b[col] * a[row,col];
                    }
                }


                for (int i = 0; i < n; i++)
                {
                    Console.WriteLine(string.Format("{0}", answer[i]));
                }

            }
        }
}

Measured memory_bytes: 9360
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

// 提出時にclass Main に書き換え
public class Main {
	public static void main(String[] args)  {
		// かがみもちの直径を格納するセットd
		Set<Integer> d = new HashSet<Integer>();
		// 標準入力を受け取る
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); // int Nを受け取る
		for(int i=0; i < N; i++) {
			int di = sc.nextInt(); // int diを受け取る
			d.add(di); // diをセットdに格納（重複した値は無視）
		}
		sc.close(); // 標準入力を終了

		// d.size()を出力
		System.out.println(d.size());
	}

}

Measured memory_bytes: 35928
"""
NTC here
"""
import sys
inp = sys.stdin.readline


def input(): return inp().strip()


flush = sys.stdout.flush
# import threading
# sys.setrecursionlimit(10**6)
# threading.stack_size(2**25)


def iin(): return int(input())


def lin(): return list(map(int, input().split()))

# range = xrange
# input = raw_input


def main():
    def fn(n):
        return (n*(n+1))//2
    n, m = lin()
    print(fn(n-1)+fn(m-1))

main()
# threading.Thread(target=main).start()


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


int main()
{
    int n,cnt = 0;
    std::map<int,bool> map;
    std::cin>>n;
    for(int i=0;i<n;i++){
        int tmp;std::cin>>tmp;
        tmp /= 400;
        if(tmp<8){
            map[tmp] = true;
        }else{
            cnt++;
        }
    }
    int max,min;
    int c = map.size();
    max = c+cnt;
    if(c==0)min = 1;
    else min = c;
    std::cout<<min<<" "<<max<<std::endl;
}

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

using namespace std;

int main(void) {
    int N, L;
    string str[100];

    cin >> N >> L;

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

    sort(str, str + N);

    string ans = "";

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

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different 
Yours Faithfully
Shobhit Yadav */

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

int A,B;
/*ll freq[200005];*/
void solve(){
	 /*memset(freq,0,sizeof(freq));*/
	cin>>A>>B;
	
	if(A>=10 || B>=10)
		cout<<-1<<'\n';

	else
		cout<<A*B<<'\n';

}



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

	return 0;
}

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


int main()
{
	int N;
	cin >> N;
	int d[N];
	for (int i=0;i<N;i++){
		cin >> d[i];
	}
	sort(d, d+N);
	int answer;
	answer = d[N/2] - d[N/2 -1];
	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 640
#define rep(i,n) for (int i=0;i<n;i++)
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const long long INF = 1LL<<60;

int main(){
  
  int N,K;
  cin >> N >> K;
  
  vector<bool> dp(K+1,false);
  vector<int> a(N);
  
  rep(j,N){

    cin >> a.at(j);
  }  
    rep(i,K+1){
      
      rep(j,N){
      if(a.at(j)<=i)
        dp.at(i)=(!dp.at(i-a.at(j))) || dp.at(i);
   
      
      } 
    } 
  
  
/*  rep(i,K+1)
    cout << dp.at(i) << endl;*/
  
  if(dp.at(K)==true)
    cout << "First" << endl;
  else
    cout << "Second" << endl;
  
}

Measured memory_bytes: 256
"use strict";
const main = (input) => {
  const compare = (a, b) => {
    return a - b;
  };
  const [a, b, c] = input.trim().split(" ").map(Number).sort(compare);
  return a + b;
};
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 30524
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie acos(-1)
#define loop(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x) for(auto &a:x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define endl "\n"
#define debug(x)  cout<<#x<<" " <<x<<endl;
#define dbg(x,y)  cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define all(v) v.begin(),v.end()
const int e = 100005;
const ll INF = 1e18+5;
vi f[e];
vi b[e];
vi v(e,0);
unordered_set<int>s;
void dfs(int u)
{
    v[u]=1;
    s.insert(u);
    for(int c:f[u])
    {
        
        if(!v[c])
        {
            dfs(c);
        }
    }
}
void solve()
{
    int n,m,k;
    cin>>n>>m>>k;
    loop(i,0,m)
    {
        int x,y;
        cin >>x>>y ;
        f[x].pb(y);
        f[y].pb(x);
    }
    loop(i,0,k)
    {
        int x,y;
        cin>>x>>y;
        b[x].pb(y);
        b[y].pb(x);
    }
    vi ans(e,0);
    for(int i=1;i<=n;i++)
    {
        
        if(v[i])
            continue;
        s.clear();
        dfs(i);
        
        int p=s.size();
        for(int u : s)
        {
            ans[u]=p-1-f[u].size();
            for(int bck : b[u])
            {
                if(s.count(bck))
                ans[u]--;
            }
        }
    }
    loop(i,1,n+1)
        cout<<ans[i]<<" ";
}
int main() {
	// your code goes here
	io;
    solve();
	return 0;
}


Measured memory_bytes: 16784
#include <iostream>
using namespace std;
int main(){
    string s; cin >> s;
    int ans;
    if (s == "SUN") ans = 7;
    else if (s == "MON") ans = 6;
    else if (s == "TUE") ans = 5;
    else if (s == "WED") ans = 4;
    else if (s == "THU") ans = 3;
    else if (s == "FRI") ans = 2;
    else ans = 1;
    cout << ans << endl;
}

Measured memory_bytes: 256