akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
string s;
int clen = 0;
int x, y;
vector<int> alen[2];
bool sol () {
  clen = 0;
  cin >> s;
  s += 'T';
  cin >> x >> y;
  int curd = 0;
  for(auto const c: s) {
    if (c == 'F') {
      clen++;
    } else {
      alen[curd].push_back(clen);
      clen = 0;
      curd = 1 - curd;
    }
  }
  /*
  cout << "----\n";
  for(auto c: alen[0]) cout << c << ' ';
  cerr << endl;
    for(auto c: alen[1]) cout << c << ' ';
  cerr << endl;
  cout << "----\n";
  */
  // check y
  int yall = 0;
  for(auto c: alen[1]) yall += c;
  if ((yall + y) % 2)  return false;
  const int ytarget = (yall + y) / 2;
  if (ytarget < 0) return false;
  if (yall - ytarget < 0) return false;
  vector<int> vy(ytarget + 1);
  vy[0] = 1;
  // y+ + y- = yall
  // y+ - y- = y
  // y+ = (yall + y) / 2
  for(auto c: alen[1]) {
    for(int k = 0; k + c <= ytarget; ++k) {
      if (vy[k]) vy[k + c] = 1; 
    }
  }
  if (vy[ytarget] == 0) {
    return false;
  }

  // check x

  // x+ + x- + x0 = xall
  // x+ - x- + x0 = x
  // xtarget = (xall + x) / 2 - x0
  const int x0 = alen[0][0];
  int xall = 0;
  for(auto c: alen[0]) xall += c;
  if ((xall + x) % 2) return false;
  const int xtarget = (xall + x) / 2 - x0;
  if (xtarget < 0) return false;
  if (xall - x0 - xtarget < 0) return false;
  vector<int> vx(xtarget + 1);
  vx[0] = 1;
  for(int i = 1; i < alen[0].size(); ++i) {
    const int c = alen[0][i];
    for(int k = 0; k + c <= xtarget; ++k) {
      if (vx[k]) vx[k + c] = 1;
    }
  }
  
  if (vx[xtarget] == 0) return false;

  return true;
}
int main () {
  bool ret = sol();
  if (ret) cout << "Yes";
  else cout << "No";
  cout << endl;
}


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

int main(){
  int h,w;
  cin>>h>>w;
  string ans="Yes";

  vector<vector<char> > v(h, vector<char>(w,'-'));
  r(i,h){
    r(j,w){
      cin>>v.at(i).at(j);
    }
  }
  int cnt=0;

  r(i,h){
    if(ans=="No")break;
    r(j,w){

      if(v[i][j]=='#'){
          if(i==0){
            cnt++;
          }else{
            if(v[i-1][j]=='.')cnt++;
          }

          if(j==0){cnt++;}
          else{if(v[i][j-1]=='.')cnt++;}

          if(i==h-1){cnt++;}
          else{if(v[i+1][j]=='.')cnt++;}

          if(j==w-1){cnt++;}
          else{if(v[i][j+1]=='.')cnt++;}
          //cout<<cnt<<" ";
          if(cnt==4){ans="No";break;}
          cnt=0;
        }
        //cout<<endl;
      }
    }

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


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
        int h[10];
        int i;
        for(i=0;i<10;i++){
                scanf("%d",&h[i]);
        }
        int j,M[3]={-1},idx;
        for(i=0;i<3;i++){
                for(j=0;j<10;j++){
                        if(h[j]>M[i]){
                                M[i]=h[j];
                                idx=j;
                        }
                }
                h[idx]=-1;
        }
        for(i=0;i<3;i++){
                printf("%d\n",M[i]);
        }
        return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int a, b,c, k, x, y;
    cin>>a>>b>>c>>k;

    if(a>=b && a>=c)
    {
        x=a;
        y=pow(2,k);

        x*=y;

        cout<<x+b+c<<endl;
    }

    else if(b>=a && b>=c)
    {
        x=b;
        y=pow(2,k);

        x*=y;

        cout<<x+a+c<<endl;
    }
    else if(c>=a && c>=b)
    {

        x=c;

        y=pow(2,k);

        x*=y;

        cout<<x+b+a<<endl;
    }
    return 0;
}



Measured memory_bytes: 4060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
typedef long long ll;
template<class T> void out(T a){cout<<a<<endl;}
void solve(){
  string s;
  cin>>s;
  ll a=s.size();
  ll n=a*(a-1)/2;
  ll b;
  char c='a';
  rep(i,26){
    ll p=0;
    rep(j,a) if(c==s[j]) p++;
    b+=p*(p-1)/2;
    c++;
  }
  out(n-b+1);
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


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

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    int a[n][m], b[m][l];
    long long c[n][l];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            cin >> b[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
           c[i][j] = 0;
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            for (int k = 0; k < m; k++) {
                c[i][j] += (a[i][k] * b[k][j]); 
            }
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            cout << c[i][j];
            if (j != l - 1) cout << ' ';
        }
        cout << endl;
    }
}


Measured memory_bytes: 3228
# D - Powerful Discount Tickets
import heapq
n,m= map(int, input().split())

a = [int(s) for s in input().split()]
a = list(map(lambda x: x*(-1), a))  # 各要素を-1倍

heapq.heapify(a)

while (m != 0):
    heapq.heappush(a, (int)(heapq.heappop(a) / 2))
    m = m - 1

print(-sum(a))

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


int main()
{
  string S;
  cin >> S;
  int count = 0; // 敗北数を数える

  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'x') {
      count++;
    }
  }

    if (count > 7)
    {
      // 8敗でNO
      cout << "NO" << endl;
    } else {
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    int num=0;
    int count=0;

    if(h>w){
        while(n>count){
            count+=h;
            num++;
        }        
    }
    if(w>=h){
        while(n>count){
            count+=w;
            num++;
        }
    }
    cout<<num<<endl;
    return 0;
}

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

from collections import defaultdict
from collections import deque

g = defaultdict(list)
idx = defaultdict(int)

for i in range(N-1):
  a, b = map(int, input().split())
  g[a].append(b)
  idx[a, b] = i

#print(g)
q = deque()
q.append((1, 0))

res = [0] * (N-1)
n = 0
while q:
  #print(q)
  node, color = q.popleft()
  
  n = max(n, color)
  i = 1
  for nei in g[node]:
    if i == color:
      i += 1
    q.append((nei, i))
    res[idx[node, nei]] = i
    i += 1
print(n)
for c in res:
  print(c)

Measured memory_bytes: 91352
#include<stdio.h>
int main(void)
{
	int x[10000],i,a;
	i=1;
	a=2;
	while(1){
		scanf("%d",&x[i]);
		a=x[i];
		i++;
	if (a == 0){
		i=1;
		 break;
	}
	}
	while(1){
		printf("Case %d: %d\n",i,x[i]);
		i++;
		if (x[i]==0){
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using VVI = vector<vector<int>>;
const int INF = 1001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int pa = 0, pb = 0;
    ll price = a * x + b * y;
    ll mini = price;
    for (int i = 0; i < 200000; i += 2) // ミックスピザを何枚注文するか
    {
        if (x > 0)
        {
            x--;
            price -= a;
        }
        if (y > 0)
        {
            y--;
            price -= b;
        }
        price += (c * 2);
        mini = min(mini, price);
    }
    cout << mini << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <ctype.h>
int main()
{
    int A,B;
    std::cin >>A>>B;
    if(A>=13){
      std::cout <<B;
    }else if(A<=5){
      std::cout << 0 << std::endl;
    }else{
      std::cout << B/2 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
//AOJ0281

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int Q;
  cin >> Q;

  for(int i=0; i<Q; i++){
    int c, a, n;
    cin >> c >> a >> n;

    int can = min(min(c, a), n);
    c -= can;
    a -= can;

    int cca = min(c/2, a);
    c -= cca*2;

    int ccc = c/3;

    cout << can+cca+ccc << endl;
  }

  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,W;
    cin >> N >> W;
    vector<ll> w(N),v(N);
    map<ll,ll> mp;
    vector<vector<ll>> memo(4);
    rep(i,N){
        cin >> w[i] >> v[i];
        mp[w[i]-w[0]]++;
        memo[w[i]-w[0]].push_back(v[i]);
    }
    rep(i,4){
        sort(memo[i].rbegin(), memo[i].rend());
    }
    vector<vector<ll>> S(4, vector<ll>(101));
    rep(i,4){
        rep(j,mp[i]){
            S[i][j+1] = memo[i][j] + S[i][j];
        }
    }
    ll ans = 0;
    rep(i,mp[0]+1){
        ll tmp = 0;
        rep(j,mp[1]+1){
            rep(k,mp[2]+1){
                rep(l,mp[3]+1){
                    tmp = S[0][i] + S[1][j] + S[2][k] + S[3][l];
                    if(W >= w[0]*(i+j+k+l) + j+k+l + k+l + l){
                        cmax(ans, tmp);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    /*
    vector<vector<Pll>> dp(N+1, vector<Pll>(404));
    rep(i,N){
        rep(j,401){
            if(dp[i+1][j+w[i+1]-w[i]].fi < dp[i][j].fi+v[i]){
                dp[i+1][j+w[i+1]-w[i]].fi = dp[i][j].fi+v[i];
                dp[i+1][j+w[i+1]-w[i]].se = dp[i][j].se+1;
            }
            if(dp[i+1][j+w[i+1]-w[i]].fi < dp[i][j].fi){
                dp[i+1][j+w[i+1]-w[i]].fi = dp[i][j].fi;
                dp[i+1][j+w[i+1]-w[i]].se = dp[i][j].se;
            }
            if(j-1 < 0) continue;
            if(dp[i+1][j+w[i+1]-w[i]].fi < dp[i][j-1].fi){
                dp[i+1][j+w[i+1]-w[i]].fi = dp[i][j-1].fi;
                dp[i+1][j+w[i+1]-w[i]].se = dp[i][j-1].se;
            }
        }   
    }
    ll ans = 0;
    rep(j,401){
        if(ans < dp[N][j].fi){
            if(dp[N][j].se*w[0] + j <= W){
                ans = dp[N][j].fi;
            }
        }
    }
    cout << ans << endl;*/
}   

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

public class Main{
	static void main() throws Exception{
		char[]s=sc.nextLine().toCharArray(),t=sc.nextLine().toCharArray();
		int ans=s.length;
		for(int i=0;i+t.length-1<s.length;i++) {
			int cur=0;
			for(int j=i,c=0;c<t.length;c++,j++) {
				if(s[j]!=t[c]) {
					cur++;
				}
			}
			ans=Math.min(ans, cur);
		}
		pw.println(ans);
	}
	public static void main(String[] args) throws Exception{
		sc=new MScanner(System.in);
		pw = new PrintWriter(System.out);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

Measured memory_bytes: 25564
/**
 *    author:  math2do
 *    created: 26.08.2020 15:12:47
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  bool found = false;
  for (int dx = 0; dx <= x; dx++) {
    int dy = x - dx;
    int total = 2 * dx + 4 * dy;
    if (total == y) {
      found = true;
      break;
    } 
  } 
  puts(found ? "Yes" : "No");
  // form 2
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define mp(a,b)	make_pair(a,b)
#define fst	first
#define scn second

const ll mod = 1e9 + 7;
const ld eps = 1e-9;

ll dp[100010];

int main() {
	int n, t;	cin >> n >> t;
	int ret = 0, s = 0, e = 0;
	rep(i, n) {
		int c;	cin >> c;
		if (c <= e)	e = c + t;
		else {
			ret += e - s;
			s = c;
			e = c + t;
		}
	}
	ret += e - s;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
import math
K=int(input())
ans=0

for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(j,K+1):
            a=math.gcd(i,j)
            a=math.gcd(a,k)
            if i==j and i==k:
              ans=ans+a
            elif i==j or i==k or j==k:
              ans=ans+3*a
            else:
              ans=ans+6*a
print(ans)

Measured memory_bytes: 9132
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int N;
	scanf("%d", &N);

	vector<int> a;
	
	for (int i = 0; i < N; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		a.push_back(tmp);
	}

	int max = *max_element(a.begin(), a.end());
	int min = *min_element(a.begin(), a.end());

	printf("%d\n", max - min);

}

Measured memory_bytes: 256
### constant

INF = 1 << 30

### subroutines

# x=vx*t+px0, y=vy*t+py0
# t = (x-px0)/vx = (y-py0)/vy
# x = (y-py0)/vy*vx+px0

def cross_x(px0, py0, px1, py1, y)
  vx = px1 - px0
  vy = py1 - py0
  (y - py0).to_f * vx / vy + px0
end

### main

loop do
  n = gets.to_i
  break if n == 0

  pts = []
  min_y = INF
  max_y = -INF
  
  n.times do
    xi, yi = gets.split.map(&:to_i)
    min_y = yi if min_y > yi
    max_y = yi if max_y < yi
    pts << [xi, yi]
  end
  pts << pts.first
  #p pts
  #p [min_y, max_y]

  count = 0

  for y0 in (min_y...max_y)
    y1 = y0 + 1
    xs0 = []
    xs1 = []

    pts.each_cons(2) do |pt0, pt1|
      if pt0[1] <= y0 && pt1[1] >= y1 ||
         pt1[1] <= y0 && pt0[1] >= y1
        xs0 << cross_x(*pt0, *pt1, y0)
        xs1 << cross_x(*pt0, *pt1, y1)
      end
    end
    xs0.sort!
    xs1.sort!

    ranges = []
    while ! xs0.empty?
      xis = [xs0.shift, xs0.shift, xs1.shift, xs1.shift]
      xmin = xis.min
      xmax = xis.max
      ranges << [xmin.floor, xmax.ceil]
    end
    #p ranges

    prv = nil
    for range in ranges
      if prv.nil?
        prv = range
      elsif range[0] <= prv[1] && prv[0] <= range[1]
        prv[0] = range[0] if prv[0] > range[0]
        prv[1] = range[1] if prv[1] < range[1]
      else        
        count += prv[1] - prv[0]
        prv = range
      end
    end
    count += prv[1] - prv[0] if prv
  end

  puts count
end

Measured memory_bytes: 6188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n), c(9, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = min(a[i], 3200);
    c[a[i]/400]++;
  }
  int count = 0;
  for (int i = 0; i < 8; i++) {
    if (c[i] > 0) count++;
  }
  
  cout << max(count, 1) << ' ' << count + c[8] << endl;
}

Measured memory_bytes: 256
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    S = input()

    i = 0
    ans = False
    while True:
        res = S[i:i + 5]
        if res == "dream":
            i = i + 5
            if S[i:i + 5] == "dream":
                continue
            elif S[i:i + 7] == "erdream":
                i = i + 2
                continue
            elif S[i:i + 5] == "erase":
                continue
            elif S[i:i + 7] == "ererase":
                i = i + 2
                continue
            elif i == len(S):
                ans = True
                break
            elif i == len(S) - 2:
                if S[i:] == "er":
                    ans = True
                    break
                else:
                    ans = False
                    break
            else:
                ans = False
                break
        elif res == "erase":
            i = i + 5
            if S[i:i + 5] == "dream":
                continue
            elif S[i:i + 6] == "rdream":
                i = i + 1
                continue
            elif S[i:i + 5] == "erase":
                continue
            elif S[i:i + 6] == "rerase":
                i = i + 1
                continue
            elif i == len(S):
                ans = True
                break
            elif i == len(S) - 1:
                if S[i:] == "r":
                    ans = True
                    break
                else:
                    ans = False
                    break
            else:
                ans = False
                break

    if ans:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 41196
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps DBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, k, a[2010];
int mypow(int x, int y) {
	if (!y)return 1;
	if (y % 2)return mypow(x, y - 1) * x % mod;
	int memo = mypow(x, y / 2);
	return memo * memo % mod;
}
signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] > a[j]) {
				ans += k * (k + 1) / 2;
				ans %= mod;
			}
		}
		rep(j, i) {
			if (a[i] > a[j]) {
				ans += k * (k - 1) / 2;
				ans %= mod;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        checked {
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
        }
#endif
    }

    static object process(TextReader input) {
        var n = long.Parse(input.ReadLine());

        counts = new DefaultDectionary<long, long>(0);

        var nums = PrimeFact(n);

        long sum = 0;
        foreach(var x in nums) {
            var c = counts[x];
            long i = 1;
            while (true) {
                c = c-i;
                if(c < 0) break;
                i++;
                sum++;
            }
        }

        return sum;
    }

    static DefaultDectionary<long, long> counts;

    static List<long> PrimeFact(long n) {
        var list = new List<long>();

        for (long i = 2; i <= Math.Sqrt(n); i++) {
            if (n % i == 0) {
                list.Add(i);
                while (n % i == 0) {
                    n /= i;
                    counts[i]++;
                }
            }
        }
        if (n > 1) {
            list.Add(n);
            counts[n]++;
        }
        return list;
    }

    class DefaultDectionary<Tkey, TValue> : Dictionary<Tkey, TValue>
    {
        TValue DefaultValue;
        public DefaultDectionary(TValue defaultvalue) {
            this.DefaultValue = defaultvalue;
        }
        public new TValue this[Tkey key] {
            get {
                if (this.ContainsKey(key)) return base[key];
                else return DefaultValue;
            }
            set {
                base[key] = value;
            }
        }
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 27792
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);

    ll n;
    cin>>n;
    int cnt=0,ans=0,st=1;
    while(n%2==0)
    {
        cnt++;
        n/=2;
        if(cnt==st)
            ans++,cnt=0,st++;
    }
    for(int i=3; i<=sqrt(n); i+=2)
    {
        cnt=0,st=1;
        while(n%i==0)
        {
            cnt++;
            n/=i;
            if(cnt==st)
                ans++,cnt=0,st++;
        }
    }
    if(n!=1)
        ans++;
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = 1e9+7;
const int MAX_N = 100005; 
ll A[MAX_N];
ll sum[MAX_N];

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
	COMinit();
	ll N,K;
	ll sumall = 0;
	cin >> N >> K;
	rep(i,N)
	{
		cin >> A[i];
	}

	if (K == 1)
	{
		cout << "0" << endl;
		return 0;
	}
	sort(A,A+N);
	sum[0] = 0;
	rep(i,N+1)
	{
		if (i < K-2)
		{
			sum[i] = 0;

		}
		else if (i == K-2)
		{
			sum[i] = 1;
		}
		else
		{
			sum[i] = (sum[i-1] + COM(i,K-2)) % MOD;
		}
		//cout << sum[i] << endl;
	}
	ll ans = 0;
	rep(i,N-K+1)
	{
		ans = (ans - (A[i] * COM(N-i-1,K-1)) % MOD) % MOD;
	}
	for (int i = K-1; i < N; ++i)
	{
		ans = (ans + (A[i] *sum[i-1]) % MOD) % MOD;
	}
	cout << ans << endl;
	return 0;
}

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

int N,M, ac = 0,pn= 0;

int main()
{
    cin >> N >> M;
    vector<int> p(M);
    vector<bool> s(M);
    for (int i = 0; i < M;i++){
        int A;
        string S;
        cin >> A >> S;
        A--;
        p[i] = A;
        if(S == "AC"){
            s[i] = true;
            
        }else{
            s[i] = false;
        }
    }
    vector<bool> t(N, false);
    vector<int> wa(N, 0);
    for (int i = 0; i < M; i++)
    {
        if(s[i] == true){
            if(t[p[i]] == false)
                ac++;
            t[p[i]] = s[i];
        }
        if(t[p[i]] == false){
            wa[p[i]]++;
        }
    }
    for (int i = 0; i < N;i++){
        if(t[i])
            pn += wa[i];
    }

        cout << ac << " " << pn << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
    long long int n, m, i, j, ans=0;
    scanf("%lld %lld", &n, &m);
    long long int sita = 1, ue = n, l[m], r[m];
    for(i=0; i<m; i++){
        scanf("%lld %lld", &l[i], &r[i]);
    }
    for(i=0; i<m; i++){
        if(sita<l[i]) sita=l[i];
        if(ue>r[i]) ue=r[i];
    }
    ans = ue-sita + 1;
    if(ans>=0) printf("%lld", ans);
    else printf("0");
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll>>      vpll;
typedef		vector<ll>      vll;


int main()
{
 //O_O ;
   ll t,n,ans=0;
   cin>>t>>n;
   for(ll i=0;i<n;i++){
      ll a;
      cin>>a;
      ans+=a;


   }
   if(ans>=t)
    cout<<"Yes"<<nn;
   else
    cout<<"No"<<nn;


    return 0;
}


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


int main(){
  ll h,n,ans=MOD;cin>>h>>n;
  vll a(n),b(n),dp(20010,MOD);
  dp[0]=0;
  rep(i,0,n){
    cin>>a[i]>>b[i];
  }
  rep(i,1,20010){
    ll tmp=MOD;
    rep(j,0,n){
      if(i-a[j]>=0){
        tmp=min(dp[i-a[j]]+b[j],tmp);
      }
    }
    dp[i]=tmp;
  }
  sort(a.begin(),a.end());
  rep(i,h,h+a[n-1]){
    ans=min(ans,dp[i]);
  }
  cout<<ans<<endl;
}





Measured memory_bytes: 384
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
      void solve(){    
                ll n,p;
                cin>>n>>p;
                if(n<=9&&p<=9){
                        cout<<n*p;
                        return ;
                }
                cout<<-1;
        }
        int main(){ 
                hs;
                ll t;
                t=1;
                // cin>>t;
                for (int i=1; i<=t; i++){
                        solve();
                 }
        return 0; 
}         
 

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

typedef long long ll;

int main(){
    int N;
    cin >> N;
    string S; 
    cin >> S;
    int left_W[N];
    int right_E[N];
    left_W[0] = (S[0] == 'W') ? 1 : 0;
    for(int i = 1; i < N; i++){
        if(S[i] == 'W'){
            left_W[i] = left_W[i-1] + 1;
        } else {
            left_W[i] = left_W[i-1];
        }
    }
    right_E[N-1] = (S[N-1] == 'E' ? 1 : 0);
    for(int i = N-2; i >=0 ; i--){
        if(S[i] == 'E'){
            right_E[i] = right_E[i+1] + 1;
        } else {
            right_E[i] = right_E[i+1];
        }
    }

    int ans = N;
    for(int i = 0; i <N; i++){
        int tmpans;
        if(i == 0){
            tmpans = right_E[1];
        } else if(i == N-1){
            tmpans = left_W[N-2];
        } else { 
            tmpans = left_W[i-1] + right_E[i+1];
        }
        if(tmpans < ans){
            ans = tmpans;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 3076
def k10tok5(a,b,c):#1枚増える
    if a >= 1:
        return (a-1, b+2, c) 
    else:
        return False
def k5tok(a,b,c):#4枚増える
    if b >= 1:
        return (a, b-1, c+5)
    else:
        return False

def ryougae(a, b, c, n, m):
    for i in range(n):
        if k10tok5(a, b, c):
            a, b, c = k10tok5(a, b, c)
        else:
            return False
    for i in range(m):
        if k5tok(a, b, c):
            a, b, c = k5tok(a, b, c)
        else:
            return False
    return a, b, c

def goukei(a,b,c):
    return a + b + c

N, Y = (int(i) for i in input().split())
a = Y//10000
b = (Y%10000)//5000
c = (Y%5000)//1000 
if N - a - b - c < 0:
    print("-1 -1 -1")
elif N - a - b - c == 0:
    print("{} {} {}".format(a,b,c))
else:
    temp = N - a - b - c
    for i in range( (temp + 4 - 1)//4 ):
        if ryougae(a, b, c, temp - 4*i, i):
            a, b, c = ryougae(a, b, c, temp - 4*i, i)
            print("{} {} {}".format(a,b,c))
            break
    else:
        print("-1 -1 -1")

        
        


Measured memory_bytes: 3064
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
m=0
flag=0
if n==1:
  ans="Yes"
else:
  for i in range(n):
    if h[i]>m:
      m=h[i]
    if h[i]+2<=m:
      ans="No"
      break
print(ans)

Measured memory_bytes: 15020
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        System.out.println(gcd(x,y));
    }
    
    public static int gcd(int x, int y) {
        int tmp = x % y;
        if (tmp == 0) {
            return y;
        }
        return gcd(y, tmp);
    }
}

Measured memory_bytes: 26320
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        string O, E;
        cin >> O >> E;
        rep(i, 0, min(len(O), len(E))) {
                cout << O[i] << E[i];
        }
        if (len(O) > len(E)) {
                cout << O.back();
        }
        cout << endl;
}

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

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

    cout << (n == 0 ? 1 : 0) << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define forout(i,a,b) for(int i=a;i>=b;--i)
#define forv(a,b) for(auto &a:b)
#define pii pair<int,int>
#define fi first
#define se second
#define sz(s) (int)(s.size())
#define pb push_back
char inchar() {char c=getchar();while(c==' '||c=='\n') c=getchar();return c;}
#define inchar inchar()
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define bit(x,i) ((x>>i)&1)
#define batbit(x,i) (x|(1ll<<i))
#define tatbit(x,i) (x&~(1ll<<i))
#define task "BUILT"
using namespace std;
const int N=1e5+5;
int id[N];
struct cl
{
    int u,v,c;
};
cl a[N],e[N];
bool dk(cl x,cl y)
{
    return x.u<y.u;
}
bool dk1(cl x,cl y)
{
    return x.c<y.c;
}
bool dk2(cl x,cl y)
{
    return x.v<y.v;
}
int root(int u)
{
    return id[u]<0?u:id[u]=root(id[u]);
}
void unf(int u,int v)
{
    if((u=root(u))==(v=root(v))) return ;
    if(id[u]>id[v]) swap(u,v);
    id[u]+=id[v];
    id[v]=u;
}
main()
{
	///freopen(task".inp","r",stdin);
	///freopen(task".out","w",stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	memset(id,-1,sizeof id);
	int n;
	cin>>n;
	forinc(i,1,n)
	{
	    int u,v;
	    cin>>u>>v;
	    a[i]={u,v,i};
	}
	sort(a+1,a+n+1,dk);
	int cnt=0;
    forinc(i,1,n-1)
    {
        int z=min(a[i+1].u-a[i].u,abs(a[i+1].v-a[i].v));
        e[++cnt]={a[i].c,a[i+1].c,z};
    }
    sort(a+1,a+n+1,dk2);
    forinc(i,1,n-1)
    {
        int z=min(abs(a[i+1].u-a[i].u),a[i+1].v-a[i].v);
        e[++cnt]={a[i].c,a[i+1].c,z};
    }
    sort(e+1,e+cnt+1,dk1);
    int kq=0;
    forinc(i,1,cnt)
    {
        int u=e[i].u,v=e[i].v,c=e[i].c;
        if(root(u)!=root(v))
        {
            unf(u,v);
            kq+=c;
        }
    }
    cout<<kq;

}


Measured memory_bytes: 2944
class Fixnum
  alias old_div /
  def /(b)
    if((self<0) ^ (b<0))
      return -(self.abs.old_div(b.abs))
    else
      return self.old_div(b)
    end
  end
end

gets.to_i.times{puts eval(gets.chomp.chop)}

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

using ll = long long;

const int MAX_N = 100010;
int par[MAX_N];
int rnk[MAX_N];

void init(int n) {
    rep(i,n) {
        par[i] = i;
        rnk[i] = 0;
    }
}

int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rnk[x] < rnk[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int main() {
    int N, M, ans = 0;
    cin >> N >> M;
    vector<int> a(M), b(M);
    rep(i, M) cin >> a[i] >> b[i];
    rep(i, M) {
        init(N);
        rep(j, M) {
            if (i == j) continue;
            unite(a[j] - 1, b[j] - 1);
        }
        rep(j, N) {
            if (same(0, j)) continue;
            ans++;
            //cout << i << j << endl;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def check(list_num,test):
  dp = [[0] * 3 for i in range(len(list_num) + 1)]

  for i in range(len(list_num)):
    for j in range(3):
      if(int(list_num[i]) == int(j)):
        dp[i + 1][j] = max(dp[i][(j + 1) % 3], dp[i][(j + 2) % 3]) + test[j]
      else:
        dp[i + 1][j] = max(dp[i][(j + 1) % 3], dp[i][(j + 2) % 3])

  return max(dp[-1])

def main():
  n,k = map(int, input().split())
  r,s,p = map(int, input().split())
  j = [r,s,p]
  janken = list(input())
  t = []
  for i in janken:
    if(i == 'r'):
      t.append(2)
    elif(i == 's'):
      t.append(0)
    elif(i == 'p'):
      t.append(1)
      
  count = 0
  list_num = [[] for i in range(k)]

  for i in range(len(t)):
    list_num[i % k].append(t[i])


  for i in range(k):
    count += check(list_num[i], j)

  print(count)

if __name__ == '__main__':
  main()


Measured memory_bytes: 18576
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <bitset>
#include <unordered_map>
#include <vector>
using namespace std;


long long fast_mod(long long a, long long b, long long p) {
    long long ans = 1 % p;
    long long tmp = a;
    for (; b > 0; b /= 2) {
        if (b % 2 == 1) {
            ans = ans * tmp % p;
        }
        tmp = tmp * tmp % p;
    }
    return ans;
}

unordered_map<int, int> mp;
vector<int> re;

int main() {
    long long n, x, m;
    cin >> n >> x >> m;
    long long tmp = x;
    int left = -1, right = -1;
    re.push_back(0);
    re.push_back(x % m);
    mp[x % m] = 1;
    for (int i = 2; i <= n; i++) {
        tmp = (tmp * tmp) % m;
        auto it = mp.find(tmp);
        if (it != mp.end()) {
            left = it->second;
            right = i - 1;
            break;
        } else {
            re.push_back(tmp);
            mp[tmp] = i;
        }
    }
    long long sum = 0, one_sum = 0;
    if (left != -1) {
        // cout << left << " " << right << endl;
        for (int i = 1; i < left; ++i) {
            sum += re[i];
        }
        for (int i = left; i <= right; ++i) {
            one_sum += re[i];
        }
        long long len = right - left + 1;
        long long new_n = n - (left - 1);
        long long s = new_n / len;
        sum += s * one_sum;
        // cout << one_sum << " " << s << endl;
        for (int i = 1; i <= new_n - s * len; i++) {
            sum += re[left + i - 1];
        }
    } else {
        for (int i = 1; i <= n; ++i) {
            sum += re[i];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 5500
import java.util.*;
class Main{

    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

        int a  = sc.nextInt();
        int b  = sc.nextInt();
        int c  = sc.nextInt();

        if((a + b + c )== 17){
            System.out.println("YES");

        }else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dp[110][4][4][4];

int main() {
	clr(dp,0);
	ll n;
	cin>>n;
	if(n<3){
		cout << pow(4,n) << endl;
		return 0;
	}
	rep(i,0,4){
		rep(j,0,4){
			rep(k,0,4){
				if(i==0&&j==1&&k==2)continue;
				if(i==1&&j==0&&k==2)continue;
				if(i==0&&j==2&&k==1)continue;
				dp[3][i][j][k] = 1;
			}
		}
	}
	rep(p,4,105){
		rep(i,0,4){
			rep(j,0,4){
				rep(k,0,4){
					rep(l,0,4){
						if(j==0&&k==1&&l==2)continue;
						if(j==1&&k==0&&l==2)continue;
						if(j==0&&k==2&&l==1)continue;
						if(i==0&&k==1&&l==2)continue;
						if(i==0&&j==1&&l==2)continue;
						dp[p][j][k][l] += dp[p-1][i][j][k];
						dp[p][j][k][l] %= MOD;
					}
				}
			}
		}
	}
	ll ans = 0;
	rep(i,0,4){
		rep(j,0,4){
			rep(k,0,4){
				ans += dp[n][i][j][k];
				ans %= MOD;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    rep(i,n){
        cin >> a[i];
        b[i]=a[i];
    }
    sort(b.begin(),b.end(),greater<int>());
    int m1=b[0];
    int m2=b[1];
    vector<int>::iterator M=max_element(a.begin(),a.end());
    size_t N=distance(a.begin(),M);
    rep(i,n){
        if(i==N){
            c[i]=m2;
        } else{
            c[i]=m1;
        }
    }
    rep(i,n){
        cout << c[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
using namespace std;

int main(){
  ll N,A,B; cin>>N>>A>>B;
  if((B-A)%2) cout<<"Borys"<<endl;
  else cout<<"Alice"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#include <set>
int main()
{
  set<string>sett;
  int no;
  cin >> no;
  string str;
  for(int i = 0; i<no; i++)
  {
    cin >> str;
    sett.insert(str);
  }
  cout << (int)sett.size();
}

Measured memory_bytes: 19260
import sys
import io
import math
import re

datalist = input().split()
num_summit = int(datalist[0])

array_1=[]
array_2=[]

array_1 = input().split()
array_2 = input().split()

sum=0

for num in range(num_summit):
    if int(array_1[num])-int(array_2[num]) > 0:
        sum += int(array_1[num])-int(array_2[num])
print(sum)


Measured memory_bytes: 3188
n=int(input())
s,p=0,-2
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
for i in a:
    s+=b[i-1]
    if p-i==-1:s+=c[i-2]
    p=i
print(s)

Measured memory_bytes: 3060
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    md=2019
    s=SI()
    n=len(s)
    vv=[0]*(n+1)
    ten=1
    for i in range(n-1,-1,-1):
        vv[i]=(vv[i+1]+int(s[i])*ten)%2019
        ten=(ten*10)%md
    vc=Counter(vv)
    ans=0
    for c in vc.values():
        ans+=c*(c-1)//2
    print(ans)

main()

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

int main(){
	int A, B;
	cin >> A >> B;
	for(int n=1;n<=1000000000;n++) {
		int a = (n * 0.08) / 1;
		int b = (n * 0.1) / 1;
		if(a == A and b == B) {
			cout << n << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long x[1000000];
int main()
{
	long long s=0,n,a,b;
	int i,j;
	cin>>n>>a>>b;
	for(i=1;i<=n;i++)
	{
		cin>>x[i];
	}
	for(i=1;i<n;i++)
	{
		if((x[i+1]-x[i])*a<b)
		s+=(x[i+1]-x[i])*a;
		else
		s+=b;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
int N,M;
vector<int>A,B,C;

signed main(){
    scanf("%lld",&N);A.resize(N);
    for(int i=0;i<N;i++)scanf("%lld",&A[i]);
    scanf("%lld",&M);
    B.resize(M);C.resize(M);
    for(int i=0;i<M;i++)scanf("%lld",&B[i]);
    for(int i=0;i<M;i++)scanf("%lld",&C[i]);

    sort(A.begin(),A.end());
    vector<int>sum(N);
    for(int i=0;i<N;i++){
        sum[i]=A[i]+(i?sum[i-1]:0);
    }


    for(int i=0;i<M;i++){
        int u=upper_bound(A.begin(),A.end(),B[i])-A.begin();
        int val;
        if(u==0)val=0;
        else val=sum[u-1];
        if(C[i]<=val)puts("Yes");
        else puts("No");
    }
    return 0;
}

Measured memory_bytes: 10176
#include<iostream>
using namespace std;
int main(){
  double v;
  while(cin >>v){
    v = v*v;
    for(double n=1;;n++){
      double y = 5*(n-1);
      if(y*2*9.8 >= v){cout <<n<<endl;break;}
    }
  }
  return 0;
}

Measured memory_bytes: 1272
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    ll n, k;
    cin >> n >> k;
    ll a = n % k;
    ll b = abs(a - k);
    cout << min(a, b) << endl;
	return 0;
} 

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

using namespace std;

int main(){
	ll n, le=2021, ri=0, i;
	
	cin>>n;
	
	vector <ll> a(n+1);
	
	for(i=1;i<=n;i++){
		cin>>a[i];
		le=min(le, a[i]);
		ri=max(ri, a[i]);
	}
	
	ri=ri-le;
	le=0;
	
	
	cout<<(ri+le)/2+(ri+le)%2<<"\n";
}


Measured memory_bytes: 3120
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;

int main() {

    int N, A, B;
    cin >> N >> A >> B;

    int answer = (A * N > B) ? B : A * N;
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256