akhauriyash/Code-Regression huggingface dataset:
while 1:
	n, q = map(int, raw_input().split(" "))
	if (n, q) == (0,0):
		break
	date_total = [0 for i in range(100)]
	for i in range(n):
		date = map(int, raw_input().split(" "))
		for j in range(1,date[0]+1):
			date_total[date[j]] += 1
	best = max(date_total)
	if best < q:
		print 0
	else :
		print date_total.index(best)

Measured memory_bytes: 4220
n, m = map(int, input().split())

ab = []
for i in range(n):
    x = list(map(int, input().split()))
    ab.append(x)

ab.sort()
ans = 0
for i in range(n):
    if m <= 0:
        break
    ans += min(m, ab[i][1]) * ab[i][0]
    m -= ab[i][1]
print(ans)


Measured memory_bytes: 27760
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '?') {
			cout << 'D';
		}
		else {
			cout << s[i];
		}
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] A = new int[M];
		int[] B = new int[M];
		Long[] H = new Long[N];
		int[] counter = new int[N];

		int i = 0;
		while(i < N) {
			H[i] = sc.nextLong();
			counter[i] = 1;
			i++;
		}

		i = 0;
		while(i < M) {
			A[i] = sc.nextInt()-1;
			B[i] = sc.nextInt()-1;
			i++;
		}

		for(i = 0; i < M;i++) {
			if(H[A[i]] > H[B[i]]) {
				if(counter[A[i]]==1) {
					counter[A[i]]=1;
					counter[B[i]]=0;
				}else {
					counter[A[i]]=0;
					counter[B[i]]=0;
				}
			}else if(H[A[i]] < H[B[i]]) {
				if(counter[B[i]]==1) {
					counter[B[i]]=1;
					counter[A[i]]=0;
				}else {
					counter[A[i]]=0;
					counter[B[i]]=0;
				}
			}else {
				counter[A[i]]=0;
				counter[B[i]]=0;
			}
		}

		int result =0;

		for(i = 0;i < N;i++) {
			if(counter[i] == 1) {
				result++;
			}
		}

		System.out.println(result);

	}

}


Measured memory_bytes: 64636
import sys

sys.setrecursionlimit(10 ** 6)

def main():
    n=int(input())
    hh=list(map(int, input().split()))
    mx=0
    pre=0
    cnt=0
    for h in hh:
        if h>pre:
            mx=max(mx,cnt)
            cnt=0
        else:
            cnt+=1
        pre=h
    mx=max(mx,cnt)
    print(mx)

main()

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin>>n;
  vll c(4);
  vector<string> v;
  v.push_back("AC");
  v.push_back("WA");
  v.push_back("TLE");
  v.push_back("RE");
  REP(i,n){
    string s;
    cin>>s;

    REP(j,4){
      if(v[j]==s)
        c[j]++;
    }
  }

  REP(i,4)
    cout<<v[i]<<" x "<<c[i]<<endl;
}



Measured memory_bytes: 3656
package main

import "fmt"

func main() {
	a, b := 0, 0
	fmt.Scanf("%d %d", &a, &b)
	begin10, end10 := b*10, b*10+9
	begin8 := (a/2)*25 + (a%2)*13
	end8 := ((a+1)/2*25 + (a+1)%2*13) - 1
	//fmt.Printf("%d %d %d %d \n", begin10, end10, begin8, end8)
	if max(begin8, begin10) <= min(end8, end10) {
		fmt.Println(max(begin8, begin10))
	} else {
		fmt.Println("-1")
	}
}
func max(a, b int) int {
	if a >= b {
		return a
	} else {
		return b
	}
}
func min(a, b int) int {
	if a <= b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 1836
import Data.List
deleteAll ch str = if elem ch str then deleteAll ch (delete ch str) else str

saveRange::Int -> Int -> [[a]] -> [[a]]
saveRange a b c = [ x | x<-c, length x>=a, length x<=b ]

func::[String] -> [String]
func strs = saveRange 3 6 strs

main = do{
    getLine>>=putStrLn.unwords.func.words.(',' `deleteAll`).('.' `deleteAll`);
}

Measured memory_bytes: 3904
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

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

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s; cin >> s;

    if (s == "SUN") {
        cout << 7 << "\n";
    } else if (s == "MON") {
        cout << 6 << "\n";
    } else if (s == "TUE") {
        cout << 5 << "\n";
    } else if (s == "WED") {
        cout << 4 << "\n";
    } else if (s == "THU") {
        cout << 3 << "\n";
    } else if (s == "FRI") {
        cout << 2 << "\n";
    } else if (s == "SAT") {
        cout << 1 << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;

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

	vi t(n);
	rep(i, n) cin >> t[i];
	sort(rev(t));

	double cost = a;
	double cal = c;
	rep(i, n){
		if(1.*cal/cost > 1.*t[i]/b) break;
		cal += t[i];
		cost += b;
	}
	int ans = cal/cost;
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;

const int MAXN = 33;
int w, n;
int a[MAXN], b[MAXN];

int main() {
  while(cin >> w) {
    cin >> n;
    for(int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      replace(s.begin(), s.end(), ',', ' ');
      stringstream ss(s);
      ss >> a[i] >> b[i];
      --a[i];
      --b[i];
    }
    int res[w];
    for(int j = 0; j < w; ++j) {
      int p = j;
      for(int i = 0; i < n; ++i) {
	if(p == a[i]) {
	  p = b[i];
	} else if(p == b[i]) {
	  p = a[i];
	}
      }
      res[p] = j;
    }
    for(int j = 0; j < w; ++j) {
      cout << res[j]+1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<ll> a(n + 1);
  for (int i = 0; i < n + 1; i++)
    cin >> a[i];

  vector<ll> b(n);
  rep(i, n) cin >> b[i];

  ll cnt = 0;

  for (int i = 0; i < n; i++)
  {
    if (b[i] <= a[i] + a[i + 1])
    {
      if (b[i] >= a[i])
      {
        a[i + 1] = a[i + 1] - b[i] + a[i];
      }
      cnt += b[i];
    }
    else
    {
      cnt += a[i] + a[i + 1];
      a[i + 1] = 0;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 9;
inline int read()
{
    int data = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        data = (data << 3) + (data << 1) + ch - '0';
        ch = getchar();
    }
    return f * data;
}
int a[maxn], b[maxn], c[maxn], dp[maxn][3];
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("data.txt","w",stdout);
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    int n = read();
    for (int i = 1; i <= n; ++i)
    {
        a[i] = read(), b[i] = read(), c[i] = read();
        dp[i][0] = a[i] + max(dp[i-1][2], dp[i-1][1]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][1], dp[i-1][0]);
    }
    printf("%d\n",max(max(dp[n][0], dp[n][1]), dp[n][2]));
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}


Measured memory_bytes: 6032
a,b=map(int,input().split())

answer = 0

upper = a
under = 0

for i in range(b):
  c,d=map(int,input().split())
  if d <= upper:
    upper = d
  if under <= c:
    under = c

if (upper - under) < 0:
  print(0)
else:    
  print(upper - under + 1)

Measured memory_bytes: 3060
import sys
n = int(input())
xyh = []
for _ in range(n):
	xyh.append(list(map(int,input().split())))

for Cx in range(101):
	for Cy in range(101):

		for x,y,h in xyh:
			if h == 0:
				continue

			H = h + abs(x - Cx) + abs(y - Cy)
			break
		ok = True
		for x,y,h in xyh:
			if max(H - abs(x - Cx) -abs(y - Cy), 0) != h:
				ok = False
				break
		if ok:
			print("{} {} {}".format(Cx, Cy, H))
			sys.exit(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int solve (int n , int k , vector<int>a,vector<int>dp)
{
  dp[1]=0;
  int ans ;
  for(int i=2;i<=n;i++)
  {ans=1e9;
    for(int j = i-1 ; j>0 && (i-j) <=k ; j--)
    { 
     ans = min(ans,abs(a[i]-a[j]) + dp[j]) ;
    }
    dp[i]=ans ; 
  }
  return dp[n] ;
  
}
int main ()
{
  int n,k; cin >> n >> k ;
  vector<int>a(n+1);
  for(int i = 1 ; i <=n;i++)
  cin >> a[i] ;
  vector<int>dp(n+1);
  fill(dp.begin(),dp.end(),-1);
  cout << solve(n,k,a,dp) ;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")

using namespace std;

using LL = long long;
template<typename T> using V = vector<T>; 
template<typename T, typename S> using P = pair<T, S>; 
using LD = long double;

#define ALL(v) v.begin(), v.end()
#define endl '\n'
#define SYNC ios_base::sync_with_stdio(false); cin.tie(NULL); cerr.tie(NULL);
#define REP(i , n) for(int i =0 ; i < n ;i++)
#define REPN(i , n) for(int i = 1; i <= n ; i++)
#define her 	cerr << " here \n"; 
#define pp push_back
#define fi first 
#define se second
#define un(x) x.erase(unique(ALL(x)), x.end())

template<typename T, typename S> void check(T & a, const S & b) { if (a >= b) { a %= b; } }
template<typename T>T gcd(T u, T v) { if (u == v)return u; if (u == 0)return v; if (v == 0)return u; if (~u & 1) { if (v & 1) return gcd(u >> 1, v); else return gcd(u >> 1, v >> 1) << 1; }if (~v & 1)return gcd(u, v >> 1); if (u > v)return gcd((u - v) >> 1, v); return gcd((v - u) >> 1, u); }

int main(){
	SYNC; 
	int n, m; 
	cin >> n >> m; 
	V<int> f(n, 0); 

	REP(i, m){
		int a, b; 
		cin >> a >> b; 
		a--; b--; 
		f[a]++; 
		f[b]++; 
	}

	REP(i, n){
		if(f[i] & 1){
			cout << "NO" << endl; 
			return 0; 
		}
	}
	
	cout << "YES\n" << endl; 
	cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
	return 0; 
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  
  cin >> N >> A;
  
  int B = N%500;
  
  if(A >= B){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
 
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
int n,wyn=1e9;
int su(int a) {
    int re=0;
    while(a) {
        re+=(a%10);
        a/=10;
    }
    return re;
}
int32_t main(void) {
    boost;
    cin>>n;
    f1(i,n-1) {
        wyn=min(wyn,su(i)+su(n-i));
    }
    cout<<wyn;
}


Measured memory_bytes: 256
N=int(input())
S=[]
ans=[-1 for x in range(N+1)]
con=[[] for x in range(N+1)]
for i in range(N-1):
    u,v,w=[int(x) for x in input().split()]
    con[u].append([v,w])
    con[v].append([u,w])
K=[]
ans[1]=0
focus=[[1,0]]
M=1
while(M<N):
    newfocus=[]
    for f in focus:
        s=f[0]
        c=f[1]
        for A in con[s]:
            d,w=A
            if ans[d]==-1:
                nc =c
                if w%2:
                    nc=not(c)
                ans[d]=nc
                newfocus.append([d,nc])
                M+=1
        focus=newfocus[:]
for i in range(1,N+1):
    print(int(ans[i]))

Measured memory_bytes: 90784
import java.util.Scanner;
public class Main {
	public static int dfs(int total, int addv, int target, int n){ return n == 0 ? total == target ? 1 : 0 : addv > 9 ? 0 : dfs(total + addv, addv + 1, target, n - 1) + dfs(total, addv + 1, target, n); }
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(true){ int n = sc.nextInt(), s = sc.nextInt(); if(n == 0 && s == 0) break; System.out.println(dfs(0, 0, s, n)); }
		}
	}
}

Measured memory_bytes: 26280
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class B01Unbalanced {
public:
    int N;
    string S;
    vc<int> sums, suff;

    int f(int mx){
        int d = 0, mn = 0;
        REP(i, N){
            if(S[i]=='?' and suff[i+1]+d+2<=mx) d += 2;
            chmin(mn, sums[i+1]+d);
        }
        return mx - mn;
    }

    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        in>>S;
        N = LEN(S);
        sums.resize(N+1, 0);
        suff.resize(N+1, 0);
        REP(i, N){
            sums[i+1] = sums[i];
            if(S[i]=='0' or S[i]=='?') sums[i+1]--;
            else sums[i+1]++;
        }
        suff[N] = sums[N];
        for(int i=N-1;0<=i;--i) suff[i] = max(suff[i+1], sums[i]);
        int z = *max_element(ALL(sums));
        out<<min(f(z), f(z+1))<<'\n';
    }
};


int main() {
	B01Unbalanced solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 12152
N = int(input())

AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
  s = input()
  if(s == "AC"):
    AC += 1
  elif(s == "WA"):
    WA += 1
  elif(s == "TLE"):
    TLE += 1
  elif(s == "RE"):
    RE += 1
    
print("AC x {}".format(AC))
print("WA x {}".format(WA))
print("TLE x {}".format(TLE))
print("RE x {}".format(RE))


  


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

int main()
{
    int N;
    int A;
    unordered_map<int, bool> map;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        if (map[A])
        {
            map.erase(A);
        }
        else
        {
            map[A] = true;
        }
    }
    cout << map.size();
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    int cnt = 0;
    for(auto s : S){
        if(s == 'A') cnt++;
    }
    if(cnt > 0 && cnt < 3) cout << YES << endl;
    else cout << NO << endl;
    return;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    int n,m;
    cin>>n>>m;
    vector<int>x(m);
    rep(i,m){
        cin>>x[i];
    }
    if(n>=m){
        cout<<0<<endl;
        return 0;
    }
    sort(x.begin(),x.end());
    vector<int>res(m-1);
    rep(i,m-1){
        res[i]=x[i+1]-x[i];
    }
    sort(res.begin(),res.end());
    int ans=0;
    rep(i,m-n)ans+=res[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
    char S[19]={};
    int i;
    scanf("%s",&S);
    for(i=0;i<19;i++){
    if('a'<=S[i] && S[i]<='z'){
        if(S[5]==',' && S[13]==','){
            S[5]=' ';
            S[13]=' ';
        }
    }
}
printf("%s",S);
return 0;
}

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

int main() {
  int R;
  cin >> R;
  if(R < 1200)
    cout << "ABC" << endl;
 if(1200 <= R && R < 2800)
    cout << "ARC" << endl;
    if(R >= 2800)
    cout << "AGC" << endl;
}

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


int main() {

    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int cnt = 0;
    for (int i = 0; i <= a; ++i) {
        for (int j = 0; j <= b; ++j) {
            for (int k = 0; k <= c; ++k) {
                if (500*i + 100*j + 50*k == x) ++cnt;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

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

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    rep(i,n-k){
        if(a[i]<a[i+k])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


Measured memory_bytes: 4772
#include <stdio.h>
int main(){
  int x,y,tem;
  while(1){
    scanf("%d %d",&x,&y);
    if(x==0&&y==0){
      break;
    }
    else if(x>y){
    printf("%d %d\n",y,x);
    }
    else if("x<=y"){
      printf("%d %d\n",x,y);
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int n,m;cin>>n>>m;
	if(n==m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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


void solve(long long N, long long M, std::vector<int> s, std::vector<int> c){
    vector<int>ret(N,-1);
    for (int i=0;i<M;i++ ){
        if (ret[s[i]-1]==-1 || ret[s[i]-1] == c[i]){
            ret[s[i]-1] = c[i];
        }else{
            printf("-1\n");
            return ;
        }
    }
    if (N==1){
        if (ret[0]>= 0){
            printf("%d\n",ret[0]);
            return ;
        }else{
            printf("0\n");
            return ;
        }

    }
    else if (ret[0] == 0) {
        printf("-1\n");
        return;
    }else if (ret[0]>0){
        printf("%d",ret[0]);
    }else{
        printf("1");
    }
    for(int i=1;i<N;i++){
        if (ret[i]>=0) printf("%d",ret[i]);
        else printf("0");
    }
    printf("\n");

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<int> s(M);
    std::vector<int> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%d",&s[i]);
        scanf("%d",&c[i]);
    }
    solve(N, M, std::move(s), std::move(c));
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

int op(int a, int b, int i){
  if(i == 0){
    return a+b;
  }
  else if(i == 1){
    return a-b;
  }
  else if(i == 2){
    return a*b;
  }
  else{
    return a/b;
  }
}

void print_op(int op1){
  if(op1 == 0){
    cout << "+";
  }else if (op1 == 1){
    cout << "-";      
  }else if (op1 == 2){
    cout << "*";      
  }else{
    cout << "/";    
  }
}

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

  int a, b, c, d;
  a = s[0]-48;
  b = s[1]-48;
  c = s[2]-48;
  d = s[3]-48;  
    
  int op1, op2, op3;

  //cout << op(7, 2, 3) << endl;
  bool f = false;
  REP(i, 4){
    REP(j, 4){
      REP(k, 4){
	int ab = 0, abc = 0, abcd = 0;
	//cout << "i: " << i << " j: " << j << " k: " << k << endl;
	if(b == 0 && i == 3){
	  continue;
	}
	ab = op(a, b, i);	  
	
	if(c == 0 && j == 3){
	  continue;
	}
	abc = op(ab, c, j);

	if(d == 0 && k == 3){
	  continue;
	}
	abcd = op(abc, d, k);
	if(abcd == 7) {
	  op1 = i;
	  op2 = j;
	  op3 = k;
	  f = true;
	  //cout << "Found" << endl;
	}	  	
      }
      if(f) break;      
    }
    if(f) break;
  }

  cout << a;
  print_op(op1);
  cout << b;
  print_op(op2);
  cout << c;
  print_op(op3);
  cout << d << "=7" << endl;
  
  return 0;
}


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

vector<long long>pati,nagasa;

tuple<long long, long long> eat(long long n, long long x){
    if (n == 0){
        if (x == 0) return forward_as_tuple(0,1);
            else return forward_as_tuple(1,1);
    }
    long long eaten = 0,l = 1,a,b;
    if (nagasa[n-1] > 0){
        if ((x>nagasa[n-1]+l) || (x == -1)){
            eaten += pati[n-1];
            l += nagasa[n-1];
        }else if (x > l){
            tie(a,b) = eat(n-1,x-l);
            eaten += a;
            l += b;
        }
    }else if ((x > 1) || (x == -1)){
        tie(a,b) = eat(n-1,x-l);
        eaten += a;
        l += b;
    }
    if (nagasa[n] == 0){
        if (nagasa[n-1] > 0){
            pati[n] = pati[n-1]*2+1;
        }else{
            tie(a,b) = eat(n-1,-1);
            pati[n-1] = a; nagasa[n-1] = b;
            pati[n] = a*2 +1;
        }
        nagasa[n] = l*2+1;
    }
    if ((x > l) || (x == -1)){
        eaten += 1; l += 1;
    }
    if ((x>nagasa[n-1]+l) || (x == -1)){
        eaten += pati[n-1];
        l += nagasa[n-1];
    }else if (x > l){
        tie(a,b) = eat(n-1,x-l);
        eaten += a;
        l += b;
    }
    if ((x > l) || (x == -1)) l += 1;
    return forward_as_tuple(eaten,l);
}

int main()
{
    long long n,x,a,b;
    cin >> n >> x;
    rep(i,n){
        pati.push_back(0); nagasa.push_back(0);
    }
    pati[0] = 1; nagasa[0] = 1;
    tie(a,b) = eat(n,x);
    cout << a << endl;
    return 0;
}

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

using namespace std;

bool comp(const int& v1, const int& v2)
{
  return v1 > v2;
}

int main()
{
  bool pr[1000001];
  int s, t, a[1001], b[1001], p, q;

  fill(pr, pr+1000001, true);
  pr[0] = pr[1] = false;
  for(int i = 2; i <= 1000000; i++){
    if(pr[i]){
      for(int j = 2*i; j <= 1000000; j+=i){
	pr[j] = false;
      }
    }
  }

  while(1){
    cin >> s >> t;
    if(s == 0 && t == 0){
      break;
    }
    p = q = 0;

    for(int i = 2; i <= s; i++){
      if(pr[i] && s%i == 0){
	a[p++] = i;
      }
    }
    for(int i = 2; i <= t; i++){
      if(pr[i] && t%i == 0){
	b[q++] = i;
      }
    }
    sort(a, a+p, comp);
    sort(b, b+q, comp);
    s = a[0];
    t = b[0];
    for(int i = 1; i < p; i++){
      s -= a[i];
    }
    for(int i = 1; i < q; i++){
      t -= b[i];
    }

    if(s > t){
      cout << "a" << endl;
    } else {
      cout << "b" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1840
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
    if a[i] < b[i]:
        b[i] -= a[i]
        ans += a [i]
        if a[i+1] <= b[i]:
            ans += a[i+1]
            a[i+1] = 0            
        else:
            ans += b[i]
            a[i+1]-=b[i]        
    else:
        ans+=b[i]        
print(ans)  

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

using namespace std;
typedef long long ll;
const int MAXN = (1 << 18) + 100;
const ll MOD = 1e9 + 7;

ll cpow (ll b, int e)
{
    if (e == 0) return 1;
    if (e == 1) return (b % MOD);
    ll v = cpow (b, e / 2);
    v = (v * v) % MOD;
    if (e % 2 == 1) v = (v * b) % MOD;
    return v;
}

ll inv (ll x)
{
    return cpow (x, MOD - 2);
}

ll mscore[MAXN];
ll iscore[MAXN];

int L, N;
int ncross[MAXN];
ll np[MAXN];

pair <ll, ll> ps[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);

    mscore[0] = 1;
    iscore[0] = 1;
    mscore[1] = 1;
    for (int i = 2; i < (1 << 18); i++)
    {
        mscore[i] = (i * mscore[i/2]) % MOD;
    }
    for (int i = 1; i < (1 << 18); i++)
        iscore[i] = inv ((mscore[i] * mscore[i/2]) % MOD);

    cin >> L;
    N = (1 << (L - 1));
    for (int i = 0; i < N; i++)
    {
        cin >> ncross[i];
        ncross[i]--;
        np[i] = (mscore[i+N] * mscore[ncross[i]+N]) % MOD;
    }

    ll ans = 0;
    for (int i = 0; i < L - 1; i++)
        for (int j = 0; j < L - 1; j++)
        {
            unordered_map <int, pair <ll, ll> > mm;
            for (int k = 0; k < N; k++)
            {
                int v = ncross[k] >> (L - 1 - j);
                int b1 = (k >> (L - 2 - i) & 1);
                int b2 = (ncross[k] >> (L - 2 - j)) & 1;
                v = 2 * v + (b1 ^ b2);
                if (b2)
                    mm[v].second += np[k];
                else
                    mm[v].first += np[k];

                if ((k + 1) % (1 << (L - 1 - i)) == 0)
                {
                    for (auto it = mm.begin(); it != mm.end(); it++)
                    {
                        if (!it->second.first || !it->second.second) continue;
                        ll l = it->second.first % MOD, l2 = it->second.second % MOD;
                        //cout << i << " " << j << " " << l << " " << l2 << "\n";

                        ll v = (l * l2) % MOD;
                        ll mask = it->first;
                        int a1 = (1<<i) + (k >> (L - 1 - i));
                        int a2 = (1<<j) + (mask / 2) % (1 << j);
                        //cout << mask << " " << a1 << " " << a2 << "\n";
                        v = v * (iscore[a1]) % MOD;
                        v = v * (iscore[a2]) % MOD;
                        ans += v;
                    }
                    mm.clear();
                }
            }
        }
    ans %= MOD;
    cout << ans << "\n";
}

Measured memory_bytes: 17696
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main(int argc, char const *argv[])
{
    ll n, max, min, sum = 0;
    cin >> n;
    vector<ll> v(n);
    for(int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        v[i] = a;
    }
    //昇順にベクターを並べる
    for(int j = 0; j < n-1; j++) {
        for(int k = j + 1; k < n; k++) {
            if(v[j] > v[k]) {
                int tmp;
                tmp = v[j];
                v[j] = v[k];
                v[k] = tmp;
            }
        }
    }

    min = v[0];
    max = v[n-1];

    //ベクターの要素の足し算
    for(int i = 0; i < n; i++) {
        ll b = v[i];
        sum += b;
    }
    
    cout << min << " " << max << " " << sum << endl;
    
    return 0;
}



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

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

    for (ll i = k; i < n; i++) {
        ll prev = A[i - k];
        ll current = A[i];
        if (prev < current) cout << "Yes" << endl;
        else cout << "No" << endl;
    }


    return 0;
}


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

const int maxn=3e5+6,p=1e9+7;
long long a[maxn],ans;
int t,cnt,n;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%lld",&a[i]);
	}
	for(int j=0;j<=60;++j) {
		cnt=0;
		for(int i=1;i<=n;++i)
			if(a[i]&(1ll<<j)) cnt++;
		ans+=((((1ll<<j)%p*cnt)%p)*(n-cnt))%p;
		ans%=p;
	}
	printf("%lld",ans%p);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
const int ZERO = 2 * 80 * 80;
std::bitset<2 * ZERO + 1> curr[80], next[80];
int a[80][80], b[80][80], nRows, nCols;
int main() {
    std::cin >> nRows >> nCols;
    for (int i = 0; i < nRows; i++) {
        for (int j = 0; j < nCols; j++) {
            std::cin >> a[i][j];
        }
    }
    for (int i = 0; i < nRows; i++) {
        for (int j = 0; j < nCols; j++) {
            std::cin >> b[i][j];
        }
    }
    curr[0][ZERO] = 1;
    for (int r = 0; r < nRows; r++) {
        std::fill(next,next+80,0);
        int d = std::abs(a[r][0] - b[r][0]);
        next[0] = (curr[0] << d) | (curr[0] >> d);
        for (int c = 1; c < nCols; c++) {
            d = std::abs(a[r][c] - b[r][c]);
            next[c] |= (next[c-1] << d) | (next[c-1] >> d);
            next[c] |= (curr[c] << d) | (curr[c] >> d);
        }
        std::copy(next,next+80,curr);
    }
    int answ = ZERO+1;
    for (int x = -ZERO; x <= ZERO; x++) {
        if (curr[nCols-1][x+ZERO]) {
            answ = std::min(answ,std::abs(x));
        }
    }
    assert(answ <= ZERO);
    std::cout << answ << std::endl;
    return 0;
}

Measured memory_bytes: 768
n = gets.to_i
a = n.times.map{
    gets.chomp
}
ans = "true"
for i in 0..n - 2
  if a[i][a[i].length - 1] != a[i+1][0]
      ans = "false"
  end
end
if a.uniq.length != a.length
    ans = "false"
end
puts ans == "false" ? "No" : "Yes"

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;
 
int main() {
int n,k;
cin>>n>>k;
map<int,int> m;
for(int i=0;i<n;i++){
    int l;
    cin>>l;
m[l]++;
}
int i=0;
vector<int> b(m.size());
int ans=0;
for(auto a : m){
b[i]=a.second;
i++;
}
sort(b.begin(),b.end());

if(i>k){
for(int j=0;j<m.size()-k;j++){
ans+=b[j];
}
}
cout<<ans<<endl;
}

Measured memory_bytes: 10368
#include<iostream>
using namespace std;
string s[]={
	"* = ****",
	"* =* ***",
	"* =** **",
	"* =*** *",
	"* =**** ",
	" *= ****",
	" *=* ***",
	" *=** **",
	" *=*** *",
	" *=**** ",
};
main()
{
    int cnt=0;
	string t;
	while(cin>>t)
	{
	    if(cnt++>0)cout<<endl;
	    while(t.size()<5)t="0"+t;
		for(int i=0;i<8;i++)
		{
			for(int j=0;j<t.size();j++)
			{
				cout<<s[t[j]-'0'][i];
			}
			cout<<endl;
		}
	}
}



Measured memory_bytes: 3032
#include<iostream>
using namespace std;
int n,m,sum1,x,mapn[55][55],visitn[55];
main(){
cin>>n>>m;
for(int i=1;i<=m;i++){
int a,b;cin>>a>>b;
visitn[a]++,visitn[b]++;
mapn[a][b]=mapn[b][a]=1;}
bool falg=true;
while(1){
falg=true;
for(int i=1;i<=n;i++){
if(visitn[i]==1){
sum1++,x=i,falg=false,visitn[i]--;break;}}
if(falg)break;
for(int i = 1;i<=n;i++){
if(mapn[x][i]==1)
visitn[i]--;}}
cout<<sum1<<endl;}

Measured memory_bytes: 256
from collections import deque

a = [int(i) for i in input().split()]
q = deque([])
for i in range(a[0]): q.append(deque([]))

for i in range(a[1]):
    cmd = [int(i) for i in input().split()]

    if cmd[0] == 0:
        q[cmd[1]].append(cmd[2])

    elif cmd[0] == 1:
        if q[cmd[1]] != deque([]): print(q[cmd[1]][0])

    elif cmd[0] == 2:
        if q[cmd[1]] != deque([]): q[cmd[1]].popleft()



Measured memory_bytes: 14528
def solve(n, p):
    result = 0
    for i in range(n-1):
        if (i+1) == p[i]:
            p[i], p[i+1] = p[i+1],p[i]
            result += 1
    i = n - 1
    if (i+1) == p[i]:
        p[i-1], p[i] = p[i],p[i-1]
        result += 1
    return result

if __name__ == '__main__':
    n = int(input())
    p = list(map(int, input().split(" ")))
    print(solve(n, p))


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

#define ll long long
#define pb push_back
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
#define ford(b,a) for(int i=b;i>=a;i--)
typedef pair<int, int> pi;
#define PI 3.14159265359
long long mod=1000000007;
//int count=INT_MAX;

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int testcases=1;
    //cin>>testcases;
    //cout<<t;
    //scanf("%d",&t);
    while(testcases--){  
        int n;
        cin>>n;
        int ac=0,tle=0,re=0,wa=0;
        fori(0,n){
            string s;
            cin>>s;
            if(s[0]=='R') re++;
            if(s[0]=='T') tle++;
            if(s[0]=='A') ac++;
            if(s[0]=='W') wa++;
            
        }
        cout<<"AC x "<<ac<<endl;
            cout<<"WA x "<<wa<<endl;
            cout<<"TLE x "<<tle<<endl;
            cout<<"RE x "<<re<<endl;
    }                                                                                          
    
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
priority_queue<long long,vector<long long>,greater<long long> >q2;//后半部分
priority_queue<long long,vector<long long>,less<long long> >q1;//前半部分
long long sum1,sum2;//qian hou
int main()
{
    long long sum1=0,sum2=0;
    long long num=0;
    int op;
    int q;
    scanf("%d",&q);
    while(q--)
    {
        scanf("%d",&op);
        if(op==1)
        {
            long long temp1,temp2;
            scanf("%lld%lld",&temp1,&temp2);
            num+=temp2;
            if(!q1.size()||temp1<q1.top()) q1.push(temp1),sum1+=temp1;
            else q2.push(temp1),sum2+=temp1;
            //维持均匀
            while(q1.size()<q2.size())
            {
                //cout<<"*";
                long long temp;
                temp=q2.top();
                q2.pop();
                q1.push(temp);
                sum2-=temp;
                sum1+=temp;
            }
            while(q1.size()-1>q2.size())
            {
                //cout<<"2";
                long long temp;
                temp=q1.top();
                q1.pop();
                q2.push(temp);
                sum1-=temp;
                sum2+=temp;
            }
        }
        else
        {
            long long sum=q1.size()+q2.size();
            long long ans;
            if(q1.size()&&q2.size())
            ans=1LL*q1.top()*q1.size()-sum1+sum2-q1.top()*q2.size()+num;
            else if(q1.size())
            {
                ans=num;
            }
//            cout<<num<<" ";
//            cout<<sum1<<" "<<sum2<<q1.size()<<" "<<q2.size()<<endl;
            printf("%lld %lld\n",q1.top(),ans);
        }
    }
}


Measured memory_bytes: 3828
// https://atcoder.jp/contests/dp/tasks/dp_h
#include <iostream>
#include <map>
#include <stack>
#include <vector>
#include <assert.h>
using namespace std;

const long long BIGINT = (long long)1e9 + 7;
int H, W;
string s;
long long dp[1005][1005];

int main()
{
    cin >> H >> W;
    for (int i = 1; i <= H; ++i) {
        cin >> s;
        for (int j = 1; j <= W; ++j) {
            int idx = j - 1;
            if (i == 1 && j == 1) dp[i][j] = 1LL;
            else if (s[idx] == '#') dp[i][j] = 0LL;
            else {
                assert (s[idx] == '.');
                dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % BIGINT;
            }
        }
    }
    cout << dp[H][W] << endl;

    return 0;
}

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

using namespace std;

int main()
{
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  for(int i = 0; i< n ;++i) cin >> p[i];
  auto result = find(p.begin(), p.end(), x);
  if (result == p.end()) {
    cout << x << endl;
  } else {
    for(int i = 1; i<= n ;++i){ 
      result = find(p.begin(), p.end(), x - i);
      if (result == p.end()) {
        cout << x - i << endl;
        break;
      }
      result = find(p.begin(), p.end(), x + i);
      if (result == p.end()) {
        cout << x + i << endl;
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3628
h, w = [int(i) for i in input().split()]

m = [None for i in range(h)]

for i in range(h):
    m[i] = str(input())

for i in range(h):
    for j in range(w):
        if m[i][j] == ".":
            a = 0
            for ii in range(-1, 2, 1):
                for jj in range(-1, 2, 1):
                    if i+ii >= 0 and j+jj >= 0 and i+ii < h and j+jj <w:
                        a += (m[i+ii][j+jj] == "#")
            a = str(a)
            m[i] = m[i][:j] + a + m[i][j+1:]

for i in range(h):
    print(m[i])

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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n,x[100010],y[100010];
struct UF{
    vector<int>par,sz;
    void init(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};
UF uf;
vector<pair<int,pint>> edge;
pair <pint,int> p1[100010],p2[100010];

signed main(){
    cin>>n;
    rep(i,0,n){
        int a,b;
        cin>>a>>b;
        p1[i]=pair<pint,int>(pint(a,b),i);
        p2[i]=pair<pint,int>(pint(b,a),i);
    }
    sort(p1,p1+n);sort(p2,p2+n);
    rep(i,0,n-1){
        pint p=p1[i].fi,q=p1[i+1].fi;
        int ct=min(abs(p.fi-q.fi),abs(p.se-q.se));
        edge.pb(pair<int,pint>(ct,pint(p1[i].se,p1[i+1].se)));
    }
    rep(i,0,n-1){
        pint p=p2[i].fi,q=p2[i+1].fi;
        int ct=min(abs(p.fi-q.fi),abs(p.se-q.se));
        edge.pb(pair<int,pint>(ct,pint(p2[i].se,p2[i+1].se)));
    }
    sort(edge.begin(),edge.end());
    int ans=0;
    uf.init(n+2);
    rep(i,0,edge.size()){
        pint p=edge[i].se;
        if(!uf.same(p.fi,p.se)){
            uf.unite(p.fi,p.se);
            ans+=edge[i].fi;
        }
    }
    cout<<ans<<endl;
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 14704
program common_raccoon_vs_monster
  implicit none
  integer :: h, n, a(100000) = 0
  read(*,*) h, n
  read(*,*) a(1:n)
  write(*,'(a)') trim(merge("No ","Yes",h > sum(a(1:n))))
end program common_raccoon_vs_monster

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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

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

    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC\n";
    else cout<<"ABC\n";

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

bool isok(int n){
	stringstream ss;
	ss << n;
	string s = ss.str();
	int m = (int)s.length();
	rep (i, m / 2){
		if (s[i] == s[m - 1 - i]) continue;
		return false;
	} // end rep
	return true;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int A, B; cin >> A >> B;

	int res = 0;
	for (int i = A; i <= B; ++i){
		res += (int)(isok(i));
	} // end for

	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <limits.h>
#include <float.h>
#include <numeric>
#include <queue>
#include <typeinfo>
#include <memory>


using namespace std;

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

#define fs first
#define sc second

vector<P> x;

int main(){
    int N, K;
    cin >> N >> K;
    if((N-1) * (N-2) / 2 < K){
        cout << -1 << endl;
        return 0;
    }

    for(int i = 1; i < N; i++){
        x.emplace_back(P(0, i));
    }

    int s = 0;
    for(int i = 1; i < N; i++){
        for(int j = i+1; j < N; j++){
            if(s < ((N-1) * (N-2) / 2) - K){
                x.emplace_back(P(i, j));
                s++;
            }
        }
    }

    cout << x.size() << endl;
    for(auto e: x){
        cout << e.fs+1 << " " << e.sc+1 << endl;
    }


    return 0;
}


Measured memory_bytes: 384
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    d, n = [int(x) for x in input().rstrip().split(" ")]

    if n == 100:
        n = 101

    print(n * (100 ** d))


if __name__ == "__main__":
    resolve()


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

const int maxn = 100010;
int n, a[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    function<bool(bool)> solve = [&](bool player) {
        int cnt = 0, g = 0;
        for (int i = 1; i <= n; i++) {
            if (!(a[i] & 1)) cnt++;
            g = __gcd(g, a[i] - (a[i] & 1));
        }
        if (cnt & 1) return player;
        if (n - cnt > 1 || *min_element(a + 1, a + n + 1) == 1) return !player;
        for (int i = 1; i <= n; i++) a[i] /= g;
        return solve(!player);
    };
    printf("%s\n", solve(1) ? "First" : "Second");
    return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S,T; cin >> S >> T;
    int N = S.size();
    int M = T.size();

    vector<int> A(N+1),B(M+1);
    rep(i,N) {
        if (S[i] == 'A') A[i+1] = 1;
        else A[i+1] = 2;
    }
    rep(i,M) {
        if (T[i] == 'A') B[i+1] = 1;
        else B[i+1] = 2;
    }
    rep(i,N) A[i+1] += A[i];
    rep(i,M) B[i+1] += B[i];

    int Q; cin >> Q;
    rep(_,Q) {
        int a,b,c,d; cin >> a >> b >> c >> d;
        int p = A[b] - A[a-1];
        int q = B[d] - B[c-1];
        cout << (p%3==q%3 ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 1744