akhauriyash/Code-Regression huggingface dataset:
n = int(input())
h = list(map(int, input().split()))

if n == 1:
    print("Yes")
else:
    h[0] -= 1
    for i in range(1,n-1):
        if h[i] >= h[i+1] and h[i-1] < h[i]:
            h[i] -= 1
        
    if h == sorted(h):
        print("Yes")
    else:
        print("No")

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll sum[100500];

int main() {
    //cout.precision(10);
    ll n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        ll a, b;
        cin >> a >> b;
        sum[a] += b;
    }
    ll now = 0;
    for(int i = 1; i <= 100000; i++) {
        now += sum[i];
        if(now >= k) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string Yes(bool f) {return (f) ? "Yes" : "No";}
string YES(bool f) {return (f) ? "YES" : "NO";}

int main () {
    string S;
    cin >> S;
    cout << Yes(S != "AAA" && S != "BBB") << endl;
}

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

using ll = long long;

int main(void){
  string s; cin >> s;
  ll ans=0;
  
  for(int bit=0;bit<(1<<s.size()-1);bit++){
    string ss = "";
    for(int i=0;i<s.size();i++){
      ss+=s[i];
      if(bit>>i&1){ //この書き方でbitが書き換わることはない
	ans+=stoll(ss);
	ss="";
      }
    }
    ans+=stoll(ss);
    ss="";
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  int CH, CW;
  cin >> CH >> CW;
  CH--, CW--;
  int DH, DW;
  cin >> DH >> DW;
  DH--, DW--;
  vector<string> S(H);
  rep(i, H) cin >> S[i];

  // 01-BFS
  deque<tuple<int, int, int>> que;
  que.emplace_front(0, CH, CW);
  vector<vector<int>> dist(H, vector<int>(W, INT_MAX));
  dist[CH][CW] = 0;
  while (!que.empty()) {
    int warp, y, x;
    tie(warp, y, x) = que.front();
    que.pop_front();
    if (y == DH && x == DW) {
      cout << warp << endl;
      return 0;
    }
    if (dist[y][x] < warp) continue;

    for (int i = -2; i <= 2; ++i) {
      for (int j = -2; j <= 2; ++j) {
        if (i == 0 && j == 0) continue;
        int ny = y + i;
        int nx = x + j;
        if (ny < 0 || nx < 0 || H <= ny || W <= nx) continue;
        if (S[ny][nx] != '.') continue;
        if ((i == 0 && (j == -1 || j == 1)) ||
            (j == 0 && (i == -1 || i == 1))) {
          if (dist[ny][nx] <= warp) continue;
          dist[ny][nx] = warp;
          que.emplace_front(warp, ny, nx);
        } else {
          int nwarp = warp + 1;
          if (dist[ny][nx] <= nwarp) continue;
          dist[ny][nx] = nwarp;
          que.emplace_back(nwarp, ny, nx);
        }
      }
    }
  }
  cout << -1 << endl;
  return 0;
}


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

int main(){
  string number;
  int i,sum = 0;

  while(1){
    cin >> number;
    if(number == "0") break;
    for(i = 0; i < number.size(); i++){
      sum += number[i] - '0';
    }
    cout << sum << endl;
    sum = 0;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
using namespace std;
int main(){
  string S;
  cin >> S;
  int L = S.size();
  string ans = "AC";
  if(S[0] != 'A'){
    ans = "WA";
  }
  int cnt = 0;
  for(int i = 1; i < L; ++i){
	  if(isupper(S[i])){
	    if(i == 1 || i == L - 1 || S[i] != 'C'){
	    ans = "WA";
	    }
	    ++cnt;
	  }
  }
  if(cnt != 1){
    ans = "WA";
  }
  cout << ans << endl;
}


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

int main(){
  int n, T;
  int c[110], t[110];
  cin >> n >> T;
  for(int i = 0;i < n;i++){
    cin >> c[i] >> t[i];
  }

  int ans = INT_MAX;
  for(int i = 0;i < n;i++){
    if(t[i] <= T){
      ans = min(c[i], ans);
    }
  }

  if(ans == INT_MAX){
    cout << "TLE" << endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}


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

int main() {
	int N, M;
  	std::cin >> N >> M;

  	std::vector<int> h(N);
	for(int i = 0; i < N; ++i)
    	std::cin >> h[i];
  
  	std::vector<int> co_h(N);
	for(int i = 0; i < M; ++i){
    	int s, d;
		std::cin >> s >> d;
      	co_h[s-1] = std::max(co_h[s-1], h[d-1]);
      	co_h[d-1] = std::max(co_h[d-1], h[s-1]);
    }
  	
	int cnt{};
	for(int i = 0; i < N; ++i) {
      	cnt += h[i] > co_h[i];
    }

	std::cout << cnt << std::endl;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll n;
  cin >> n;
  map<string, ll> mp;
  REP(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }

  ll cnt = 0;
  for (auto x : mp) {
    cnt = max(cnt, x.second);
  }

  vector<string> ans;
  for (auto x : mp) {
    if (x.second == cnt) ans.push_back(x.first);
  }

  sort(ALL(ans));

  REP(i, ans.size()) { cout << ans[i] << endl; }
  return 0;
}

Measured memory_bytes: 26868
fun main(args : Array<String>) {
  val (n, a, b) = readLine()!!.split(" ").map { it.toInt() }
  val l = readLine()!!.split(" ").map { it.toInt() }
  print((1 until l.size).map { listOf(a.toLong() * (l[it] - l[it - 1]), b.toLong()).min()!! }.sum())
}


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

using namespace std;

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

  string s;
  cin >> s;
  string hi = "hi";
  rep(i, 5) {
    if (s == hi) {
      cout << "Yes" << endl;
      return 0;
    }
    hi += "hi";
  }

  cout << "No" << endl;
}

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

int main() {
  int N,i;
  cin >> N;
  int sum = 0;
  for(i=0;i<N;i++){
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}

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

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

	int count = 0;
	int m = max(a,b);
	for (int i = m; 1 <= i; --i) {
		if (a % i == 0 && b % i == 0) {
			++count;
			if (count == k) {
				cout << i << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    int N, ans = 0;
    string S;
    cin >> N >> S;
    for (int c = 0; c < 1000; c++) {
        string T = "00" + to_string(c);
        T = T.substr(T.size() - 3, 3);
        int i = 0;
        for (auto &s : S) {
            if (T[i] == s) {
                i++;
            }
            if (2 < i) {
                ans++;
                break;
            }
        }
    }
    cout << ans << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,a[100003];
map<int,int>mp;
long long ans=1;
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i+1];
	a[0]=-1;mp[0]=3;
	for(int i=1;i<=n;i++)
		ans=ans*mp[a[i]]%1000000007,
		mp[a[i]+1]++,
		mp[a[i]]--;
	cout<<ans;
}

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

int main() {
	int N;
	cin >>N;
	vector<long long> hei;
	long long H,Hpre;
	cin >> H;
	Hpre=H;
	hei.push_back(H);
	for (int i=0;i<N-1;i++){
		cin >> H;
		if(Hpre!=H){
			hei.push_back(H);
		}
		Hpre=H;
	}
	N=hei.size();
	if(N==0){
		cout << "Yes"<<endl;
	}
	else{
		bool pro = true;
		bool pro1 = true;
		bool pro2 = true;
		H=hei.at(0);
		Hpre=H;
		for(int i=1;i<N;i++){
			H=hei.at(i);
			if(H<=Hpre-2){
				pro = false;
				break;
			}
			else if(H==Hpre-1){
				pro1=false;
				if(pro1==false && pro2==false){
					pro=false;
					break;
				}
			}
			pro2=pro1;
			pro1=true;
			Hpre=H;
		}
		
		if(pro){
			cout<<"Yes"<<endl;
		}
		
		else{
			cout << "No"<<endl;
		}
	}
}


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

int main() {
  ll n;
  cin >> n;
  vl l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
  ll ans = 0;
  rep(i,n) {
    for (ll j = i+1; j < n; j++) {
      for (ll k = j+1; k < n; k++) {
        if ( (l[i] != l[j]) && (l[j] != l[k]) && l[k] < (l[i] + l[j]) )
          ans++;
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int n, k, a[101010];
void solve(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	
	k--;
	int ans = INF;
	for(int i = k; i < n; i++){
		chmin(ans, a[i]-a[i-k]);
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll MN = 1e5+5;
ll n, k;
ll R, S, P;
string t;
ll arr[MN];
ll score[MN];
ll dp[2][MN];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    cin >> R >> S >> P;
    cin >> t;
    for (ll i = 0; i<n;i++) {
        if (t[i] == 'r') {
            arr[i] = R;
            score[i] = P;
        }
        else if (t[i] == 's') {
            arr[i] = S;
            score[i] = R;
        }
        else {
            arr[i] = P;
            score[i] = S;
        }
    }
    ll ans = 0;
    for (ll i = 0; i<k;i++) {
        dp[1][i] = score[i];
        //take = 1
        //leave = 0
        dp[0][i] = 0;
        ll last = i;
        for (ll j = i+k; j<n;j+=k) {
            if (t[j] == t[j-k]) {
                dp[0][j] = max(dp[1][j-k], dp[0][j-k]);
                dp[1][j] = dp[0][j-k] + score[j];
            }
            else {
                dp[0][j] = max(dp[1][j-k], dp[0][j-k]);
                dp[1][j] = max(dp[1][j-k], dp[0][j-k]) + score[j];
            }
            last = j;
        }
        ans += max(dp[0][last], dp[1][last]);
    }
    cout << ans << "\n";
}

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




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


    ll a,b;
    cin>>a>>b;
    ll ans = 1;
    if(b==1){
        cout << 0 << endl;
        return 0;
    }
    int cnt = 0;
    while(ans<b){
        ans+=a;
        ans--;
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#16:44
a,b = map(int,input().split())
while b > 0:
  a,b = b,a%b
prime = []
for i in range(2,int(a**.5)+1):
  if a % i == 0:
    p,q = i,0
    while a % i == 0:
      a //= i
      q += 1
    prime.append([p,q])
if a != 1:
  prime.append([a,1])
print(len(prime)+1)

Measured memory_bytes: 3064
x, y = map(int, input().split())
flag = 0
for i in range(0, 1000):
    for j in range(0, 1000):
        if 2 * i + 4 * j == y and i + j == x:
            flag = 1
            break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 64492
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int d[N], T;
long long dp[N];
long long calc_big(int j) {
	return T - d[j] + dp[j];
}
long long calc_small(int j) {
	return 2LL * (-d[j + 1]) - d[j] + dp[j];
}
struct cmp_big {
	bool operator () (const int &i, const int &j) {
		return calc_big(i) > calc_big(j);
	}
};
struct cmp_small {
	bool operator () (const int &i, const int &j) {
		return calc_small(i) > calc_small(j);
	}
};
int main() {
	int n, E;
	scanf("%d%d%d", &n, &E, &T);
	for (int i = 1; i <= n; ++ i) scanf("%d", &d[i]);
	priority_queue<int, vector<int>, cmp_big> q1;
	priority_queue<int, vector<int>, cmp_small> q2;
	q1.push(0);
	for (int i = 1; i <= n; ++ i) {
		while (!q1.empty() && 2LL * (d[i] - d[q1.top() + 1]) >= T) {
			q2.push(q1.top());
			q1.pop();
		}
		dp[i] = 1e18;
		if (!q1.empty()) {
			int j = q1.top();
			dp[i] = min(dp[i], d[i] + calc_big(j));
		}
		if (!q2.empty()) {
			int j = q2.top();
			dp[i] = min(dp[i], 3LL * d[i] + calc_small(j));
		}
		q1.push(i);
	}
	cout << dp[n] + E - d[n] << endl;
}



Measured memory_bytes: 2300
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  n = readline() |> parseInt
  l = readline() |> split |> parseArray

  sort!(l)
  ans=0
  for i in 1:n
    a=l[i]
    for j in i+1:n
      b=l[j]
      m=0
      n-j==0 && continue
      for h in ceil(Int,log2(n-j)):-1:0
        k=min(j+m+2^h,n)
        c=l[k]
        m+=(c<a+b ? 2^h : 0)
      end
      k=min(j+m,n)
      ans+=k-j
    end
  end
  println(ans)
end

main()


Measured memory_bytes: 113944
import heapq
def dijkstra_heap(s,edge,n):
    d = [float("inf")] * n
    used = [True] * n
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v],e[1]))
    return d

n,m = map(int,input().split())
graph = [[] for _ in range(n)]
for i in range(1,n):
    graph[i].append((0,i-1))
for i in range(m):
    l,r,c = map(int,input().split())
    graph[l-1].append((c,r-1))
ans = dijkstra_heap(0,graph,n)[-1]
if ans == float("inf"):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 80448
#!/usr/bin/env python

from math import sqrt

if __name__ == '__main__':
    n = int(input())
    f = 10**10
    for i in range(1, int(sqrt(n))+1):
        a = i
        b = n//a

        if a*b == n:
            f = min(max(len(str(a)), len(str(b))), f)

    print(f)



Measured memory_bytes: 3060
x, y, a, b, c = map(int,input().split())
datp = sorted(list(map(int, input().split())), reverse=True)
datq = sorted(list(map(int, input().split())), reverse=True)
datr = sorted(list(map(int, input().split())), reverse=True)
dat = sorted(datp[:x] + datq[:y] + datr, reverse=True)
print(sum(dat[:x+y]))

Measured memory_bytes: 111084
import java.util.*;
    public class Main {
    	public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
    		// 整数の入力
    		int n = sc.nextInt();
    		// スペース区切りの整数の入力
			int i = sc.nextInt();
			// 出力
    		System.out.println((n)-(i-1));
    	}
    }


Measured memory_bytes: 22608
import java.util.Scanner;

class Main{
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		StringBuilder str=new StringBuilder(s.next()
				.replaceAll("eraser","")
				.replaceAll("dream","D")
				.replaceAll("er","R")
				.replaceAll("as","A"));
		String[] m={"RAe","DR","D"};
		loop:
		while(true){
			for(String b:m){
				if(str.toString().endsWith(b)){
					str.delete(str.length()-b.length(),str.length());
					continue loop;
				}
			}
			break;
		}
		System.out.println(str.length()==0?"YES":"NO");
	}
}

Measured memory_bytes: 221096
import sys
readline = sys.stdin.readline

S = readline().rstrip()
X,Y = map(int,readline().split())

# ("指示","回数")の形式に変換する
C = [] 
import itertools
for key,g in itertools.groupby(S):
  C += [[key,len(list(g))]]

x = 0
y = 0
ind = 0
if C[0][0] == "F": # 最初からX軸方向に進む場合
  x += C[0][1]
  ind += 1

# X軸方向を向いている
dirX = True

Xset = {x}
Yset = {y}

for i in range(ind, len(C)):
  command, num = C[i]
  if command == "F":
    if dirX:
      next_Xset = set()
      for x in Xset:
        next_Xset.add(x + num)
        next_Xset.add(x - num)
      Xset = next_Xset
    else:
      next_Yset = set()
      for y in Yset:
        next_Yset.add(y + num)
        next_Yset.add(y - num)
      Yset = next_Yset
  else:
    if num % 2 == 1:
      dirX ^= True

if X in Xset and Y in Yset:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 10180
#include <stdio.h>
int main(void)
{
  long long n, min = 1000000, max = -1000000, sum = 0, i, k;
  scanf("%lld",&n);
  for (i = 0; i < n; i++){
    scanf("%lld",&k);
    sum = sum + k;
    if (k < min) {min = k;}
    if (k > max) {max = k;}
  }
  printf("%lld %lld %lld\n",min,max,sum);
  return 0;
}



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

#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    string n;
    cin>>n;
    int c=n[n.size()-1]-'0';
    if(c==2 || c==4 || c==5 || c==7 || c==9) cout<<"hon";
    else if((c>=0 && c<=1) || c==6 || c==8) cout<<"pon";
    else cout<<"bon";
    cout<<endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    double ans = 0;
    double a;
    for(int i = 0; i < N; i++){
        cin >> a;
        ans += (1/a);
    }
    ans = 1/ans;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int n;
    cin >> n;
    vvi cnt(10,vi(10,0));
    for(int i=1;i<=n;i++){
        string s = to_string(i);
        cnt.at(s.at(0)-'0').at(s.at(s.size()-1)-'0')++;
    }
    long ans = 0;
    for(int i=1;i<=n;i++){
        string s = to_string(i);
        ans += cnt.at(s.at(s.size()-1)-'0').at(s.at(0)-'0');
    }
    cout << ans << endl;
}


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

import math 
L=int(math.sqrt(x))

FACT=dict()

for i in range(2,L+2):
    while x%i==0:
        FACT[i]=FACT.get(i,0)+1
        x=x//i

if x!=1:
    FACT[x]=FACT.get(x,0)+1

ANS=1
for j in FACT:
    ANS*=(j**(FACT[j]//N))

print(ANS)

Measured memory_bytes: 3064
n,k = map(int,input().split())
a_list = list(map(int,input().split()))
count = 0
for i in range(n):
    for j in range(i,n):
        if a_list[i] > a_list[j]:
            count += 1

tmp_list = [0]*n
for i in range(n):
    cnt = 0
    for a in a_list:
        if a_list[i] > a:
            cnt += 1
    tmp_list[i] = cnt
res = k * (2*count + sum(tmp_list) * (k-1)) // 2 
print(res % (10**9+7))

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

int main(){
  int R, G, B;
  cin >> R >> G >> B;
  int num = R * 100 + G * 10 + B;
  if(num % 4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s; cin >> s;
  int c0 = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '0') {c0++;}
  }
  int c1 = s.size()-c0;
  cout << min(c0,c1)*2 << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

#define rep(i, n) for(long int i = 0; i < n; i++)
#define P pair<int, int>


int main(){
    int n, m;
    cin >> n >> m;
    int ans[n];
    fill(ans, ans + n, -1);
    ans[0] = 0;
    vector<int> g[n];
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<P> q;
    q.push(P(0, 0));
    while(q.size() > 0){
        P p = q.front();
        q.pop();
        int u = p.first;
        int d = p.second;
        rep(i, g[u].size()){
            if(ans[g[u][i]] != -1) continue;
            ans[g[u][i]] = u + 1;
            q.push(P(g[u][i], u));
        }
    }
    cout << "Yes" << endl;
    rep(i, n - 1){
        cout << ans[i+1] << endl;
    }
}


Measured memory_bytes: 10628
#include<iostream>

using namespace std;

int main()
{
  int k;
  cin>>k;
  int a,b;
  cin>>a>>b;
  for(int i = a ; i<=b; i++){
    if(i%k==0){
      cout<<"OK"<<endl;
      return 0 ;
    }
  }
  cout<<"NG"<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

  string t = "";
  rep(i, sz(s)) {
    if (s[i] == 'A')
      t.pb('X');
    else if (s[i] == 'B') {
      if (i + 1 < sz(s) && s[i + 1] == 'C') {
        t.pb('Y');
        i++;
      } else
        t.pb('Z');
    } else
      t.pb('Z');
  }

  ll ans = 0;
  ll tempX = 0;
  rep(i, sz(t)) {
    if (t[i] == 'X')
      tempX++;
    else if (t[i] == 'Y')
      ans += tempX;
    else
      tempX = 0;
  }

  cout << ans << endl;
}

Measured memory_bytes: 776
#include<iostream>

using namespace std;
const int MOD=1e9+7;
typedef long long ll;

int main()
{
    ll a, b, c, d, n, m;
    cin>>n>>m;
    b=1;
    if(n-m!=1 && n-m!=0 && n-m!=-1)
    {
        cout<<0;
        return 0;
    }
    for(a=2; a<=n; a++)
    {
        b*=a;
        b%=MOD;
    }
    c=1;
    for(a=2; a<=m; a++)
    {
        c*=a;
        c%=MOD;
    }
    ll ans=c*b;
    ans%=MOD;
    if((m+n)%2==0)
    {
        ans*=2;
        ans%=MOD;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(): return "".join(list(map(str, ans)))

a = input()
v = "a e i o u".split()
if(a in v):
    print("vowel")
else:
    print("consonant")


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

//using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


int main(void)

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

	string s;
	cin >> s;
	ll count = 0;
	ll ans = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
			count++;
		else
		{
			ans = max(ans, count);
			count = 0;
		}
	}
	ans = max(ans, count);
	cout << ans << endl;

	return 0;
}

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

using namespace std;

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

    long long y, ans = 0;

    for( long long x = 1; x <= n; x++ )
    {
        y = n / x;
        ans += (( y * ( y + 1 ) * x ) / 2 );
    }

    cout << ans << "\n";    
    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  string z;
  cin >> z;
  int res = 0;
  int ak = 0;
  for(char el:z){
    if(el == 'B'){
      ak ++;
    }else{
      res += ak;
    }
  }
  cout << res << "\n";
}


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

#define F first
#define S second
#define int long long
#define ull unsigned long long
#define pb push_back

using namespace std;
const int N = 210000;
int n, c, k, t[N], ans;
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> c >> k;
    for (int i = 0; i < n; i++){
        cin >> t[i];
    }
    sort(t, t + n);
    int s = -1;
    int f = -1;
    for (int i = 0; i < n; i++){
        if (f < t[i] || s == 0){
            f = t[i] + k;
            s = c - 1;
            ans++;
        } else s--;
    }
    cout << ans;
}


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

using std::string;

int main () {
  int n;
  string str;

  std::cin >> n;
  std::cin.ignore();
  
  for (int i = 0; i < n; i++) { 
    std::getline(std::cin, str);

    size_t pos;
    while ((pos = str.find("Hoshino")) != string::npos) {
      str[pos+6] = 'a';
    }
    
    std::cout << str << std::endl;
  }
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FL "a"
using namespace std;
typedef long long ll;
typedef long double dd;
const int N=2e5+10;
const int inf=2147483647;
const dd pi=acos(-1);
const ll INF=1ll<<60;
const int mod=998244353;
inline ll read(){
  ll data=0,w=1;char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')data=data*10+ch-48,ch=getchar();
  return data*w;
}
inline void file(){
  freopen(FL".in","r",stdin);
  freopen(FL".out","w",stdout);
}

int d[N];pair<int,int>s[10];
int main()
{
  for(int i=1,u,v;i<=3;i++){
    u=read();v=read();
    s[i].first=u;s[i].second=v;
    d[u]++;d[v]++;
  }
  sort(s+1,s+3+1);
  for(int i=2;i<=3;i++)if(s[i]==s[i-1])return puts("NO"),0;
  for(int i=1;i<=4;i++)if(d[i]>=3)return puts("NO"),0;
  return puts("YES"),0;
}


Measured memory_bytes: 256
#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()
{
  int n;
  cin>>n;
  vector<pair<int,int>> v(n);
  double sum=0;
  rep(i,n)cin>>v[i].first>>v[i].second;

  int count=0;
  sort(v.begin(),v.end());

  do{
    rep(i,n-1){
      sum+=sqrt((v[i].first-v[i+1].first)*(v[i].first-v[i+1].first)+(v[i].second-v[i+1].second)*(v[i].second-v[i+1].second));
    }
    count++;
  }while(next_permutation(v.begin(),v.end()));

  printf("%.7lf\n",sum/count);
  return 0;
}


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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n;  //nは奇数
    cin>>n;
    int a[n];
    ll mt[n];
    ll dam[n];
    int i, j;
    int dam_min = 2000000000;
    int dam_min_idx;
    for(i=0; i<n; i++){
        cin>>a[i];
        dam[i] = a[i];
        if(dam[i]<dam_min){
            dam_min = dam[i];
            dam_min_idx = i;
        }
        mt[i] = 0;
    }
    int kaisu = 0;
    for(i=0; i<n; i++){
        if(i%2==0){
            mt[0] += dam[i];
        }
        else{
            mt[0] -= dam[i];
        }
    }
    cout<<mt[0]<<" ";
    for(i=1; i<n; i++){
        if(i!=n-1){
            mt[i] = 2*dam[i-1] - mt[i-1];
            cout<<mt[i]<<" ";
        }
        else{
            mt[i] = 2*dam[i] - mt[0];
            cout<<mt[i]<<endl;
        }
    }



    return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n,m,qn;

int vs[505][505]={};
int gone[505];

bool dfs(int no,int gl){
	if(no==gl)return true;
	gone[no]=1;
	reg(to,1,n){
		if(gone[to])continue;
		if(vs[no][to]>0){
			if(dfs(to,gl)){
				vs[no][to]--;
				vs[to][no]++;
				return true;
			}
		}
	}
	return false;
}

int main(void){
	scanf("%d%d%d",&n,&m,&qn);
	rep(i,m){
		int a,b;
		scanf("%d%d",&a,&b);
		vs[a][b]=vs[b][a]=1;
	}
	
	int nf=0;
	for(;;){
		memset(gone,0,sizeof(gone));
		if(dfs(1,n))nf++;
		else break;
	}
	rep(q,qn){
		int t,a,b;
		scanf("%d%d%d",&t,&a,&b);
		if(t==1){
			vs[a][b]=vs[b][a]=1;
			memset(gone,0,sizeof(gone));
			if(dfs(1,n))nf++;
		}
		else{
			int fr=-1,to;
			if(vs[a][b]==0){
				fr=a; to=b;
			}
			else if(vs[b][a]==0){
				fr=b; to=a;
			}
			vs[a][b]=vs[b][a]=0;
			if(fr>=0){
				memset(gone,0,sizeof(gone));
				if(!dfs(fr,to)){
					bool ok=true;
					memset(gone,0,sizeof(gone));
					ok &= dfs(n,to);
					memset(gone,0,sizeof(gone));
					ok &= dfs(fr,1);
					nf--;
				}
				memset(gone,0,sizeof(gone));
				if(dfs(1,n))nf++;
			}

		}
		printf("%d\n",nf);
	}
	return 0;
	
}

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

using namespace std;

int main(){
     int N,M;
    cin >> N >> M;

    vector<long int> a(M + 1);
    for( int i = 0; i < M; i++) cin >> a[i];
    vector<int> dp(N + 1,0);
    /*a[M] = 1000000007;*/
    dp[0] = 1;
    int j = 0;
    if(a[j] == 1){ dp[1] = 0; j++; }
    else{ dp[1] = 1;}
   
   for(int i = 2; i <= N; i++){
       
       
       if(i == a[j]){ dp[i] = 0; j++; }
       else{ dp[i] = dp[i - 1] + dp[i - 2];
           
             } 
            
     dp[i] %= 1000000007;

   }

   cout << dp[N] << endl;
    return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int x,a,b,c;
    while(scanf("%d%d%d%d",&a,&b,&c,&x)!=EOF)
    {
        int ans=0;
        for (int i=0;i<=a;i++)
            for (int j=0;j<=b;j++)
            for (int k=0;k<=c;k++)
            if (500*i+100*j+50*k==x) ans++;
        printf("%d\n",ans);
    }
    return 0;
}


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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define endl '\n'
#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;

void test()
{
	int n;
	ll ans=0;
	cin>>n;

	for(int i=1;i<=n;i++)
	{
		if(!((i%3==0 && i%5==0) || i%3==0 || i%5==0))
		{
			ans+=i;
		}

	}
	cout<<ans;
}

int main()
{   
fast_io();
cout << fixed << setprecision(15);
int t = 1;

//cin>>t;

for(int i = 0; i < t; i++)
{
	test();
}
return 0;
}

Measured memory_bytes: 3596
#include <cstdio>

int main() {
  //入力
  int a,b;
  std::scanf("%d %d",&a,&b);
  
  if(a < b) {
    std::printf("a < b");
  }
  else if(a > b) {
    std::printf("a > b");
  }
  else if(a == b) {
    std::printf("a == b");
  }
  std::printf("\n");
  
  return 0;
}


Measured memory_bytes: 2740
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int m = stdIn.nextInt();
    int[] s = new int[m];
    int[] p = new int[m];

    for(int i=0; i<m; i++) {
      int k = stdIn.nextInt();
      for(int j=0; j<k; j++) {
        int a = stdIn.nextInt();
        s[i] += Math.pow(2,a-1);
      }
    }

    for(int i=0; i<m; i++) {
      p[i] = stdIn.nextInt();
    }

    int N = (int)Math.pow(2,n);


    int ans = 0;
    for(int i=0; i<N; i++) {
      int flag = 1;
        for(int j=0; j<m; j++) {
          int cnt = i&s[j];
          int bits = 0;
          while(cnt != 0) {
            if((cnt&1) == 1) { bits++; }
            cnt >>>= 1;
          }
          if(bits%2 != p[j]) {
            flag = 0;
            break;
          }
        }
      if(flag == 1) { ans++; }
    }

    System.out.println(ans);
  }
}


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

typedef long long LL;

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

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cout<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;

//{
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();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int ans;
string s;

main(){
    cin>>s;
    string o="CODEFESTIVAL2016";
    rep(i,16)if(s[i]!=o[i])ans++;
    dans;
}



Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(N);
    READV(M);
    READV(K);
    char A[N][M];
    ll ans[N][M];
    vector<pll> S;
    FORI(i,0,N)
    {
        FORI(j,0,M)
        {
            READ(A[i][j]);
            ans[i][j]=0;
            if(A[i][j]=='#')
            {
                ans[i][j]=K;
                K--;
                S.pb({i,j});
            }
        }
    }
    FORI(i,0,sz(S))
    {
        FORD(j,S[i].se-1,-1)
        {
            if (ans[S[i].fi][j]==0)
            {
                ans[S[i].fi][j]=ans[S[i].fi][S[i].se];
            }
            else
            {
                break;
            }
            
        }
        FORI(j,S[i].se+1,M)
        {
            if (ans[S[i].fi][j]==0)
            {
                ans[S[i].fi][j]=ans[S[i].fi][S[i].se];
            }
            else
            {
                break;
            }
        }
    }
    FORI(i,1,N)
    {
        FORI(j,0,M)
        {
            if(ans[i][j]==0)
            {
                ans[i][j]=ans[i-1][j];
            }
        }
    }
    FORD(i,N-1,-1)
    {
        FORI(j,0,M)
        {
            if(ans[i][j]==0)
            {
                ans[i][j]=ans[i+1][j];
            }
        }
    }
    FORI(i,0,N)
    {
        FORI(j,0,M)
        {
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }

    return 0;
}

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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] a = s.toCharArray();
        long n = (long) a.length;
        long[] rec = new long[26];
        for(char w:a) rec[w-'a']++;
        long ans = 1+n*(n-1)/2;
        for(int i=0;i<26;i++){
            ans -= rec[i]*(rec[i]-1)/2;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 26552
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
ll mod=1000000007 ;
int main() {
 ll n,k ;
 cin >> n>> k ;
 vector<ll> A(n) ;
 rep(i,n) cin >> A[i] ;
 //sortしてない
 vector<ll> migi(n) ;
 rep(i,n-1){
   rep2(j,i+1,n-1){
     if(A[i]>A[j]) migi[i]  ++ ;
   }
 }
 ll migisum=0 ;
 rep(i,n) migisum+=migi[i] ;
 vector<ll> mog(n) ;
 rep(i,n){
   rep(j,n) if(A[i]>A[j]) mog[i] ++ ;
 }
 ll mogsum =0 ;
 rep(i,n) mogsum+=mog[i] ;
 ll gm= mogsum*((k*(k-1)/2)%mod) ;
 
 cout <<(migisum*k+gm)%mod<<endl ;
     return 0;
}

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

int main() {
	int N;
	int A[200];
	int count = 0;
	int s = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	
	while(1){

		for (int i = 0; i < N; i++) {
			if (A[i]%2==0) {
				A[i] = A[i] / 2;
			}
			else {
				s++;
			}
			
		}
		if (s==0) {

		}
		else {
			break;
		}
		count++;
	}
	cout << count << endl;
}

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

using namespace std;

typedef long long ll;
const int N = 300300;
const int mod = 998244353;
#define int long long
#define M(x) (((x) + mod) % mod)

int n, a, b, k, c[N], inv[N], s[N], t[N], fac[N], ans, inv2[N];

inline int qpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) (res *= a) %= mod;
    (a *= a) %= mod, b >>= 1;
  }
  return res;
}

inline void prework() {
  fac[0] = s[0] = 1; inv[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
  for (int i = 1; i <= n; i++) s[i] = 1ll * s[i - 1] * fac[i] % mod;
  t[n] = qpow(s[n], mod - 2);
  for (int i = n; i >= 1; i--) t[i - 1] = 1ll * t[i] * fac[i] % mod;
  for (int i = 1; i <= n; i++) inv[i] = 1ll * t[i] * s[i - 1] % mod;
}

inline ll C(int M, int N) {
  if (N < 0 || N > M) return 0;
  return M(1ll * fac[M] * M(inv[N] * inv[M - N]));
}

signed main() {
  scanf("%lld%lld%lld%lld", &n, &a, &b, &k);
  prework();
  for (int x = 0, y; x <= n; x++)
    if ((k - a * x) % b == 0) {
      y = (k - a * x) / b;
      ans += M(1ll * C(n, x) * C(n, y));
    }
  printf("%lld\n", M(ans));
  return 0;
}

Measured memory_bytes: 10496
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// 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();
}

//
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

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

  int a, b;
  cin >> a >> b;

  if (a > b) swap(a, b);

  if ((a + b) % 2 == 0)
    cout << (a + b) / 2 << endl;
  else
    cout << "IMPOSSIBLE" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz 200002
#define pb push_back
#define ff first
#define ln '\n'
#define ss second
#define ll long long
#define VEC vector<ll int>v
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{

int ara[]={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};
int n;
cin>>n;
cout<<ara[n-1]<<endl;


}


Measured memory_bytes: 256