akhauriyash/Code-Regression huggingface dataset:
program sample
    implicit none
  
    integer(8) :: i,j,m,n,a
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n,m
    a=0
    if (n>=m)then
        write(*,*)0
        stop
    end if
    allocate(x(m),y(m-1))
    read(*,*)x
    call msort(x)

    do i=1,m-1
        y(i)=x(i+1)-x(i)    
    end do
    call msort(y)
    
    do i=1,m-n
        a=a+y(i)
    end do
    write(*,*) a
  
    stop
    contains
    recursive subroutine msort(x)
    implicit none
    integer(8), intent(inout) :: x(:)
 
    integer(8) :: n, mid, i, j, k
    integer(8), allocatable :: tmp(:)
    
    n = size(x)
    
    if(n == 1) then
      return
    end if
 
    !
    ! 前半と後半に分けてソート
    ! 1~midとmid+1~nをそれぞれソート済みにする
    !
    mid = n / 2
    call msort(x(:mid))
    call msort(x(mid+1:))
 
    !
    ! tmpという配列にxを一時的に保管
    ! マージソートは外部ソート
    !
    allocate(tmp(n))
    tmp = x
 
    ! tmpの後半部分を左右反転
    do k = n, mid+1, -1
      tmp(k) = x(mid + n - k + 1)
    end do
 
    ! iは前半のリストのうちまだ見ていないものの最小値
    ! jは後半のリストのうちまだ見ていないものの最小値
    ! kは見た回数の合計
    i = 1
    j = n
 
    do k = 1, n
      !
      ! 一番左と一番右のうち小さい方をxに入れていく
      ! ここが等号つき不等号なので、安定ソートとなる
      !
      if(tmp(i) <= tmp(j)) then
        x(k) = tmp(i)
        i = i + 1
      else
        x(k) = tmp(j)
        j = j - 1
      end if
    end do
    
    deallocate(tmp)
    return
  end subroutine msort
end program sample
  



Measured memory_bytes: 5272
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    vector<ll> a_sum(n + 1);
    a_sum[0] = 0;
    _rep(i, 1, n + 1) a_sum[i] = a_sum[i - 1] + a[i - 1];

    int ans = 0;
    rep(i, n){
        if(a_sum[i] * 2 >= a[i]) ans++;
        else ans = 0;
    }
    cout << ans + 1 << endl;
}

Measured memory_bytes: 1792
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   if(Arr.length==0)break;
   var n=Arr.shift();
   var arr=Arr.shift().split(" ").map(Number);
   arr.sort(function(a,b){return a-b;});
   var sum=0;
   var time=0;
   arr.forEach(function(v){
      sum+=v+time;
      time+=v;
   });
   console.log(sum);
}

Measured memory_bytes: 10040
hours_p_distance, hours_q_distance, hours_r_distance = map(int, input().split())

root_p_q = hours_p_distance + hours_q_distance
root_p_r = hours_p_distance + hours_r_distance
root_q_r = hours_q_distance + hours_r_distance

if hours_p_distance == 0 or hours_q_distance == 0 or hours_r_distance == 0:
    print(max(root_p_q, root_p_r, root_q_r))
else:
    print(min(root_p_q, root_p_r, root_q_r))

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
using ii = long long;
const ii inf = 1e18;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    vector<ii> dp(n, inf);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        for (int j = 1; j <= k; ++j) {
            if (i - j < 0) break;
            dp[i] = min(dp[i], dp[i - j] + abs(v[i] - v[i - j]));
        }
    }
    cout << dp.back() << "\n";
}


Measured memory_bytes: 1408
#include<cstdio>
#include<cstring>
using namespace std;

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

int t, ans[N][N];
int n, m, k;

int main()
{
	scanf("%d%d%d", &n, &m, &k);
	int x = 1, y = 1, d = 0;
	memset(ans, 0, sizeof ans);
	for (int i = 1; i <= k; i ++){
		scanf("%d", &t);
		for (int j = 1; j <= t; j ++){
			if (x >= 1 && x <= n && y >= 1 && y <= m && !ans[x][y]){
				ans[x][y] = i;
				x += dx[d];
				y += dy[d];
			}
			else{
				x -= dx[d];
				y -= dy[d];
				d = (d + 1) % 4;
				x += dx[d];
				y += dy[d];
				ans[x][y] = i;
				x += dx[d];
				y += dy[d];
			}
		}
	}
	for (int i = 1; i <= n; i ++){
		for (int j = 1; j < m; j ++) printf("%d ", ans[i][j]);
		printf("%d\n", ans[i][m]);
	}
	return 0;
}

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

if a == 1 and b == 1:
    print(1)
if a == 1 and b != 1:
    print(b-2)
if a != 1 and b == 1:
    print(a-2)
if a != 1 and b != 1:
    print(a*b-2*(a+b)+4)

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

int main() {
    int n, k;
    cin >> n >> k;
    int a[n + 1];
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    bool dp[k + 1];
    for(int i = 0; i <= k; i++) {
        dp[i] = false; //first wins
    }
    for(int i = 1; i <= k; i++) {
        for(int j = 1; j <= n; j++) {
            //cout << dp[i] << " " << i << endl;
            if(i - a[j] < 0 || dp[i] == true)
                continue;
            if(dp[i - a[j]] == false)
                dp[i] = true;
            //cout << dp[i] << " second " << i << endl;
        }
    }
    if(dp[k] == false)
        cout << "Second" << endl;
    else
        cout << "First" << endl;
    return 0;
}


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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s;
  cin >> s;

  if (s[0] == 'A') {
    int cnt = 0;
    for (int i = 2; i < s.size() - 1; i++) {
      if (s[i] == 'C') cnt++;
    }
    if (cnt == 1) {
       bool flag = true;
    for (int i = 1; i < s.size(); i++) {
      if (s[i] == 'C') continue;
      if ('A' <= s[i] && s[i] <= 'Z') flag = false;
    }
    if (flag) {
      cout << "AC" << endl;
      return 0;
    }
    }
  }

  cout << "WA" << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int n; cin>>n;
    vector<P> A(n);
    for(int i=0; i<n; i++){
        int a; cin>>a;
        A[i] = P(a, i);
    }

    sort(all(A), greater<P>());

    vector<vector<ll>> dp(n+1, vector<ll>(n+1, -INF));
    dp[0][0] = 0;

    for(int i=0; i<n; i++){
        ll a, idx;
        tie(a, idx) = A[i];

        for(int j=0; j<=i; j++){
            int l = j, r = i - j;
            if(dp[l][r] == -INF) continue;
            chmax(dp[l+1][r], dp[l][r] + a * abs(l - idx));
            chmax(dp[l][r+1], dp[l][r] + a * abs((n - 1 - r) - idx));
        }
    }

    ll ans = -INF;
    for(int i=0; i<=n; i++) chmax(ans, dp[i][n-i]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 34616
xy = [list(map(int, input().split())) for _ in range(3)]
d = [((xy[i][0] - xy[i + 1][0]) ** 2 + (xy[i][1] - xy[i + 1][1]) ** 2) ** .5
     for i in range(-1, 2)]
s = abs((xy[1][0] - xy[0][0]) * (xy[2][1] - xy[0][1])
        -(xy[2][0] - xy[0][0]) * (xy[1][1] - xy[0][1])) / 2

k = max(d)
r = 2 * s / sum(d)
x = k * r / (k + 2 * r)
print('{:.10f}'.format(x))

Measured memory_bytes: 3316
import sys

def menseki(x0,y0,x1,y1,x2,y2):
    return 0.5*abs((x1-x0)*(y2-y0)-(x2-x0)*(y1-y0))

def square_menseki(x0,y0,x1,y1,x2,y2,x3,y3):
    return 0.5*abs((x0*y1-y0*x1)+(x1*y2-y1*x2)+(x2*y3-y2*x3)+(x3*y0-y3*x0))

for row in sys.stdin:
    x0,y0,x1,y1,x2,y2,x3,y3 = list(map(float, row.strip().split(',')))
    s = square_menseki(x0,y0,x1,y1,x2,y2,x3,y3)
    if s > menseki(x0,y0,x1,y1,x2,y2) and s > menseki(x0,y0,x1,y1,x3,y3) and s> menseki(x0,y0,x2,y2,x3,y3) and s > menseki(x1,y1,x2,y2,x3,y3):
        print('YES')
    else:
        print('NO')
    


Measured memory_bytes: 5580
N = int(input())
A = [0]+list(map(int, input().split()))+[0]
cost = []
for i in range(N+1):
    cost.append(abs(A[i]-A[i+1]))
sum_cost = sum(cost)
for i in range(1,N+1):
    print(sum_cost+abs(A[i-1]-A[i+1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1])))

Measured memory_bytes: 65900
#include<stdio.h>

int main()
{
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    if(x == a){
        printf("%d",b);
    }
    else if(a == b){
        printf("%d",x);
    }
    else if(x == b){
        printf("%d",a);}


}


Measured memory_bytes: 128
import java.util.*;

class Main{
	public static void main(String args[]) throws Exception{
		Scanner sc = new Scanner(System.in);
		int ans = 700;
		String s = sc.next();
		for(int i = 0; i < 3; i++){
			if(s.charAt(i) == 'o') ans += 100;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	lli A, B, C;
	cin >> A >> B >> C;
	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
		cout << 0 << endl;
	}
	else {
		cout << min({ A * B,B * C,C * A }) << endl;
	}
	return 0;
}


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


int main(void){
int a,b,c,d,e;
scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
if(a==0){printf("1");}
if(b==0){printf("2");}
if(c==0){printf("3");}
if(d==0){printf("4");}
if(e==0){printf("5");}
}


Measured memory_bytes: 1664
import java.util.*;
import java.io.*;
import java.math.BigInteger;

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);

	while ( stdin.hasNextLine() ) {
	    final String input = stdin.nextLine();

	    boolean flag = true;
	    for ( char ch = '0'; ch <= '9'; ch++ ) {
		String replaced = input.replace( 'X', ch );
		String[] splited = replaced.split( "[+=]" );
		if ( !isFrontZero( splited ) && sumEqual( splited ) ) {
		    System.out.println( ch );
		    flag = false;
		    break;
		}
	    }
	    if ( flag ) {
		System.out.println( "NA" );
	    }
	}
    }

    static boolean isFrontZero ( String[] array ){
	for ( String str : array ) {
	    if ( str.length() >= 2 && str.charAt( 0 ) == '0' ) {
		return true;
	    }
	}
	return false;
    }

    static boolean sumEqual ( String[] array ) {
	final BigInteger a = new BigInteger( array[0] );
	final BigInteger b = new BigInteger( array[1] );
	final BigInteger c = new BigInteger( array[2] );
	return a.add( b ).equals( c );
    }    
}

Measured memory_bytes: 23660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG


signed main() {
  string S; cin >> S;
  int K; cin >> K;
  
  vector<int> vec(0);
  int k = 0;
  char c = S[0];
  rep(i, S.size()) {
    if(S[i] == c) k++;
    else {
      vec.push_back(k);
      k = 1;
      c = S[i];
    }
    if(i == S.size()-1) vec.push_back(k);
  }
  
  //rep(i, vec.size()) cout << vec[i] << endl;
  
  int ans = 0;
  if(S[0] == S[S.size()-1]) {
    if(vec.size() > 1) {
      rep(i, vec.size()-2) {
        ans += (vec[i+1]/2)*K;
      }
      ans += ((vec[0]+vec[vec.size()-1])/2)*(K-1);
      ans += vec[0]/2 + vec[vec.size()-1]/2;
    } else {
      ans += (vec[0]*K)/2;
    }
  } else {
    rep(i, vec.size()) {
      ans += (vec[i]/2)*K;
    }
  }
  
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll A, B, K;
    cin >> A >> B >> K;

    if(A - K >= 0) { _PS(A-K); _PR(B); }
    else if(A + B - K >= 0) { _PS(0); _PR(A+B-K); }
    else { _PS(0); _PR(0); }

    return 0;
}

/*



*/

Measured memory_bytes: 256
import math
a=int(input())
b=list(map(int,input().split()))
c=sum(b)
d=0
e=float("inf")
f=0
for i in b:
  d+=i
  if abs((c/2)-d)<e:
    e=abs((c/2)-d)
    f=d
print(abs(c-f*2))

Measured memory_bytes: 88016
_ = input()
A = list(map(int, input().split()))
for i in A:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            result = "APPROVED"
        else:
            result = "DENIED"
            break
    else:
        result = "APPROVED"
print(result)


Measured memory_bytes: 38400
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#define REP(i,n) for(i=0;i<n;i++)
#define ll long long
#define PI M_PI

int main(void){
    int i;
    int N, ctr = 0;
    scanf("%d",&N);

    REP(i,N){
        if(i%2==0) ctr++;
    }
    
    printf("%f",(double)ctr/N);
    return 0;
}

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

int main( void )
{
    char s[ 5 ];
    cin >> s;
    if ( s[ 0 ] == s[ 1 ] || s[ 1 ] == s[ 2 ] || s[ 2 ] == s[ 3 ] )
    {
        cout << "Bad" << endl;
    }
    else
    {
        cout << "Good" << endl;
    }

    return 0;
}


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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;


void solve(){
    string s;
    cin>>s;
    if(s == "ABC") cout<<"ARC";
    else cout<<"ABC";
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



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

import sys


def string_to_list_spliter():
    h, w = [int(i) for i in sys.stdin.readline().split()]
    return h, w


def generate_ractangle(h, w):
    rect = ''
    for i in range(h):
        for j in range(w):
            rect += '#'
        rect += '\n'
    return rect


def main():
    while True:
        h, w = string_to_list_spliter()
        if h == 0 and w == 0:
            break
        print(generate_ractangle(h, w))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7748
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int h,w;cin>>h>>w;
    char c[h][w];
    int ta=0;
    rep(i,h)rep(j,w){
        cin>>c[i][j];
        if(c[i][j]=='#')ta++;
    }
    queue<pair<int,int>> que;que.push({0,0});
    ta--;
    int roty[2]={1,0},rotx[2]={0,1};
    while(que.size()){
        int y=que.front().first,x=que.front().second;que.pop();
        if(y==h-1&&x==w-1)break;
        rep(i,2){
            int ny=y+roty[i],nx=x+rotx[i];
            if(ny<0||ny>=h||nx<0||nx>=w)continue;
            if(c[ny][nx]!='#')continue;
            c[ny][nx]='.';
            ta--;
            que.push({ny,nx});break;
        }
    }
    if(ta!=0)cout<<"Impossible"<<endl;
    else cout<<"Possible"<<endl;
}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    ll i,j,n,m,k,cnt=0,ans=0,t=1;
    string s;
    cin>>s;
    rep(i,0,s.length()-1){
        if(s[i]==s[i+1]) ret("Bad")
    }
    ret("Good")
    return 0;
}

Measured memory_bytes: 256
n = int(input())
c = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']


def dfs(k, s):
    if len(s) == n:
        print(s)
        return
    for i in range(k):
        dfs(k, s+c[i])
    dfs(k + 1, s + c[k])


dfs(1, 'a')

Measured memory_bytes: 4412
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  int N, K;
  string S;
  cin >> N >> S >> K;
  
  string ans = "";
  char a = S[K-1];

  for(int i=0;i<N;i++){
  	if(S[i]!=a){
  		ans += '*';
  	}else{
  		ans += a;
  	}
  }
  
  cout << ans <<endl;



  return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <math.h>
#include <stdio.h>

#define arrayLength(array) (size_t)((sizeof array) / (sizeof array[0]))

char *solve(char *s) {
  for (int i = 0; i < 4; i++) {
    if (s[i] == s[i + 1] && s[i + 1] == s[i + 2]) {
      return ("Yes");
    }
    if ((i + 2) >= 4) {
      return ("No");
    }
  }
}

int main() {
  int n = 0, m = 0, x = 0, y = 0, z = 0;

  char s[255];
  char t;

  //   scanf(" %d %d %d %d", &n, &m, &x, &y);
  scanf("%s", &s);
  printf("%s", solve(s));

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <list>
#include <string>
using namespace std;

void lcs(string s, string t)
{
	vector<int> fill(t.size() + 1);
	vector<vector<int>> dp(s.size() + 1, fill);

	for (int i = 1; i <= s.size(); i++)
	{
		for (int j = 1; j <= t.size(); j++)
		{
			if (s[i - 1] == t[j - 1])
			{
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else
			{
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}

	stack<char> ans;

	int i = s.size();
	int j = t.size();

	while (i > 0 && j > 0)
	{
		if (s[i - 1] == t[j - 1])
		{
			ans.push(s[i - 1]);
			i--;
			j--;
		}
		else if (dp[i-1][j] > dp[i][j-1])
		{
			i--;
		}
		else
		{
			j--;
		}
	}

	while (!ans.empty())
	{
		cout << ans.top();
		ans.pop();
	}
	cout << "\n";
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	string s, t;
	cin >> s >> t;

	lcs(s, t);
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
long long a[1005];
int main(){
//	freopen("a.txt","r",stdin);
	a[0]=a[1]=1;
	for(int i=2;i<=44;i++)
		a[i]=a[i-2]+a[i-1];
	int n;cin>>n;cout<<a[n]<<endl;
	return 0;
}


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

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

    int d1[n], d2[n];

    for(int i = 0; i < n; i++){
        cin >> d1[i] >> d2[i];
    }

    for(int i = 0; i < n; i++){
        int count = 0;
        if(d1[i] == d2[i]){
            count += 1;
            int j = i + 1;

            while(d1[j] == d2[j]){
                count += 1;

                if(count == 3){
                    cout << "Yes" << endl;
                    return 0;
                }
                j += 1;
            }
            i = j - 1;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3600
def main():
    n = int(input())
    xx = [0] + list(map(int, input().split())) + [0]
    all_cost = sum(abs(xx[i+1] - xx[i]) for i in range(n+1))
    for i in range(n):
        a, b, c = xx[i:i+3]
        print(all_cost - abs(b - a) - abs(c - b) + abs(c - a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 67052
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long mtjkn=0;
		int[] po;
		while(true) {
			mtjkn=0;
			int ninzu=sc.nextInt();
			if(ninzu==0) {
				break;
			}
			else {
				po=new int[ninzu];
				for(int i=0; i<ninzu; i++) {
					po[i]=sc.nextInt();
				}
				Arrays.sort(po);

				for(int i=0; i<ninzu-1; i++) {
					mtjkn+=po[i]*(ninzu-1-i);
				}
				System.out.println(mtjkn);
			}
		}
	}
}


Measured memory_bytes: 47356
#include<bits/stdc++.h>
using namespace std;
#include<vector>
#include<queue>
#define ll long long
#define inf INT_MAX
main()
{
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
	cin>>a[i];
       }
	vector<int>p;
	int b[n+1];
	b[0]=0;
for(int i=1;i<=n;i++)
     b[i]=0;
    for(int i=n;i>0;i--)
	{
		   b[i]=a[i];
		for(int j=i*2;j<=n;j+=i)
		{
			b[i]^=b[j];
		}
	}
	for(int i=1;i<=n;i++)
	{
	    if(b[i])
		p.push_back(i);
	}
	cout<<p.size()<<endl;
	for(int i=0;i<p.size();i++)
	    cout<<p[i]<<" ";

}


Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)
	var t int
	switch {
	case B <= C:
		t = 0
	case C < B && B <= D:
		switch {
		case A <= C:
			t = B - C
		case C < A:
			t = B - A
		}
	case D < B:
		switch {
		case A <= C:
			t = D - C
		case C < A && A <= D:
			t = D - A
		case D < A:
			t = 0
		}
	}
	fmt.Println(t)
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define int long long
signed main(){
//int main() {
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int cnt=0;
    int xa=0;
    int xb=0;
    int r=0;

    for(int l = 0; l < n; l++) {
        while(r < n && (int)(xa^a[r])==xb+a[r]){
            //cout << l << " " << r << "\n";
            xa^=a[r];
            xb+=a[r];
            r++;
        }
        if(r==l) r++;
        else{
            xa^=a[l];
            xb-=a[l];
            cnt+=(r-l);
        }
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 5160
#include<stdio.h>

#define PI 3.141592653589793

int main(void)
{
    double r,area,cir;
    scanf("%lf", &r);
    area = PI*r*r;
    cir = 2*PI*r;
    printf("%lf %lf\n", area, cir);

    return 0;

}


Measured memory_bytes: 2060
#include <stdio.h>
int main(void){
    int m,f,r,sum;
    
    while(1){
        scanf( "%d %d %d\n" , &m , &f , &r );        
        sum = m + f;
        
        if( m == -1 && f == -1 && r == -1 ){
            break;
        }else if( m == -1 || f == -1 ){
            printf("F\n");
        }else if( sum >= 80 ){
            printf("A\n");
        }else if( sum >= 65 ){
            printf("B\n");
        }else if( sum >= 50 ){
            printf("C\n");
        }else if( sum >= 30 ){
            if( r >= 50 ){
                printf("C\n");   
            }else{
                printf("D\n");
            }
        }else{
            printf("F\n");            
        }
    }
}


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

public class Main {
    public static void main(final String[] args) {
        final FastReader s=new FastReader();
        int n = s.nextInt();
        int last = 0;
        long sum = 0;
        while (n-- > 0)
        {
            int x = s.nextInt();
            if(x<last) {
                sum+= last-x;
            }
            last = Math.max(last, x);
        }
        System.out.println(sum);
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try { st = new StringTokenizer(br.readLine()); }
                catch (final IOException  e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }
        String nextLine() {
            String str = "";
            try { str = br.readLine(); }
            catch (final IOException e) { e.printStackTrace(); }
            return str;
        }
    }
}

Measured memory_bytes: 53148
#include <iostream>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int A[100][100];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  int B[100];
  for (int i = 0; i < m; i++) {
    cin >> B[i];
  }

  int C[100] = {};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      C[i] += A[i][j] * B[j];
    }
  }

  for (int i = 0; i < n; i++) {
    cout << C[i] << endl;
  }

  return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0; i<n; i++)
    cin >> a.at(i);
  long long ans = 0;
  for(int i=0; i<k; i++) {
    ans += a.at(i);
  }
  long long temp = ans;
  for(int i=0; i<n-k; i++) {
    temp -= a.at(i); 
    temp += a.at(k+i);
    if(temp > ans) {
      ans = temp;
    }
  }
  printf("%10.3lf\n", (ans + k) / 2.0);
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		StringBuilder sb = new StringBuilder();
		int numOfLeft = 0;
		int numOfFirst = 0;
		for (int i = 0; i < n; i++) {
			char c = s.charAt(i);
			if (c == '(') {
				numOfLeft++;
			} else if (numOfLeft == 0) {
				numOfFirst++;
			} else{
				numOfLeft--;
			}
			sb.append(c);
		}
		for (int i = 0; i < numOfLeft; i++) {
			sb.append(')');
		}
		for (int i = 0; i < numOfFirst; i++) {
			sb.insert(0, '(');
		}
		System.out.println(sb.toString());
	}
}

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


namespace AtCoderPractice
{
    class Program
    {
        static void Main(string[] args)
        {
            long A = long.Parse(Console.ReadLine());
            long B = long.Parse(Console.ReadLine());
            long C = long.Parse(Console.ReadLine());
            long X = long.Parse(Console.ReadLine());

            long ans = 0;

            for(var a =0; a<=A; a++)
            {
                for (var b = 0; b <= B; b++) 
                {
                    for (var c = 0; c <= C; c++)
                    {
                        if (500 * a + 100 * b + c * 50 == X) ans++;  
                     }
                }
            }

            Console.WriteLine(ans);

        }
    }
}


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

int main() {
  int A,B;
  int flg=-1;
  cin>>A>>B;
  for(int i=0;i<1010;i++){
    if(floor(i*0.08)==A && floor(i*0.1)==B){flg=i;break;}
  }
  cout<<flg<<endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

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

void solve() {
    string s;
    cin >> s;
    int cnt = 0;
    REP(i,0,s.size()) if (s[i] == 'p') ++cnt;
    cout << s.size() - (s.size() + 1) / 2 - cnt << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  string s,t,u;
  cin>>s;
  REP(i,s.size())t+=s[s.size()-1-i];
  REP(i,t.size()){
    if(t[i]=='b')u+="d";
    else if(t[i]=='d')u+="b";
    else if(t[i]=='p')u+="q";
    else u+="p";
  }
  if(s==u)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 640
from collections import deque
def dfs(v,N,memo):
    ans =0
    if not False in memo.values():
        return 1
    for u in E[v]:
        if memo[u]!=True:
            memo[u] = True
            ans += dfs(u,N,memo)
            memo[u] = False
    return ans
N,M = list(map(int,input().split()))
memo = {i:False for i in range(1,N+1)}
E = {i: []for i in range(1,N+1)}
for i in range(M):
    u,v = list(map(int,input().split()))
    E[v].append(u)
a =0
b = 0
counter =0
for i in range(1,N+1):
    if E[i]:
        if a<max(E[i]):
          if b>max(E[i]):
            a = max(E[i])
            continue
          a = max(E[i])
          b = i
          counter +=1
print(counter)

Measured memory_bytes: 37608
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

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

    map <char, int> mp;
    int i;
    for(i = 0; i < s.length(); i ++)
    {
    	mp[s[i]] ++;
    	if(mp[s[i]] == 2)
    		break;
    }

    if(i == s.length())
    	cout << "yes" << endl;
    else
    	cout << "no" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

#define INF (1<<31-1)
#define ll long long

int N;
int a[100001+2];

int main(){

	cin >> N;

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

	int sum=0;
	for (int i = 1; i <= N + 1; i++){
		sum += abs(a[i] - a[i - 1]);
	}

	for (int i = 1; i <= N; i++){
		if (a[i - 1] <= a[i] && a[i] <= a[i + 1]) cout << sum << endl;
		else if (a[i - 1] >= a[i] && a[i] >= a[i + 1]) cout << sum << endl;
		else cout << sum - (abs(a[i-1]-a[i])+abs(a[i]-a[i+1])-abs(a[i-1]-a[i+1])) << endl;
	}



	return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>

int main(void)
{
	int ka, ki, ku, i = 0, x;

	scanf("%d %d %d", &ka, &ki, &ku);

	for (x = ka; x <= ki; x++){

		if (ku % x == 0)
		i++;

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

Measured memory_bytes: 596
#include <iostream>
#include <complex>
#include <cmath>
#include <stdio.h>

using namespace std;
int n,x,y;
int p1[110],p2[110];
double ans;
int main() {
	cin >> n;
	for (int i=0; i<n; i++){
		cin >> p1[i] >> p2[i];
		
	}
	for (int i=0; i<n; i++){
		int j = (i+1)%n;
		ans += p1[i]*p2[j];
		ans -= p1[j]*p2[i];
	}
	printf("%.1f\n", ans/2);
}

Measured memory_bytes: 3200
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;
const int INF = 1 << 30;

int main()
{
	long double T[128][128], dp[128][128];
	int n, m;

	while(cin >> n >> m)
	{
		if(n == 0 && m == 0)
		{
			break;
		}

		for(int i = 0; i < n; i++)
		{
			for(int j = 0; j < n; j++)
			{
				cin >> T[i][j];
			}
		}
		
		memset(dp, -1, sizeof(dp));
	
		for(int i = 0; i < n; i++)
		{
			dp[0][i] = 1.0;
		}

		for(int i = 1; i < m; i++)
		{
			for(int j = 0; j < n; j++)
			{
				dp[i][j] = -1.0;
				for(int k = 0; k < n; k++)
				{
					//dp[i][j] : i回目で肥料jを使った時の最大の苗木の大きさ
					dp[i][j] = max(dp[i][j], dp[i-1][k]*T[k][j]);
				}
			}
		}

		long double res = -1; 
		for(int i = 0; i < n; i++)
		{
			res = max(res, dp[m-1][i]);
		}
	
		printf("%.2Lf\n",res);
	}
}

Measured memory_bytes: 1708
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
          var a = cin.ReadInt;
          var b = cin.ReadInt;
          WriteLine(a * b % 2 == 0? "Even" : "Odd");
            // 解答はココに書く
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Stack;


class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	

	void solve(){
		Scanner in = new Scanner(System.in);

		int m = in.nextInt();

		for(int i = 0; i < m; i++){
			int sx =in.nextInt(), sy = in.nextInt(), w = in.nextInt(), h = in.nextInt();
			int n = in.nextInt(), ans = 0;
			for(int j = 0; j < n; j++){
				int x = in.nextInt(), y = in.nextInt();
				if(x >= sx && y >= sy && x <= sx + w && y <= sy + h) ans++;
			} 
			System.out.println(ans);
		}
		
		
	}
	

}

Measured memory_bytes: 33248
#include <iostream>

int main() {
  int A;
  int B;

  std::cin >> A >> B;

  if (A <= 8 && B <= 8) {
    std::cout << "Yay!" << std::endl;
  } else {
    std::cout << ":(" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 200005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	string a,b;
	cin>>a;
	for(ll i=0;i<a.length();i++){
		cout<<'x';
	}

	return 0;
}

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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 1; i <= (n); ++i)
#define rag(con) std::begin(con), std::end(con)

int main()
{

    int h, w;

    std::cin >> h >> w;

    std::multiset<int> set;
    rep(i, w)
        set.insert(0);
    std::map<int, int> mp; //終点；始点

    rep(i, w)
        mp[i] = i;

    rep(i, h)
    {
        int a, b;

        std::cin >> a >> b;

        auto bg = mp.lower_bound(a), ed = mp.upper_bound(b);

        int mx = 0;

        for (auto it = bg; it != ed; ++it)
        {
            mx = it->second;
            set.erase(set.find(it->first - it->second));
        }

        //std::cerr << "D " << mx << std::endl;

        if (mx != 0)
        {

            mp.erase(bg, ed);

            if (b < w)
            {

                if (mp[b + 1] < mx)
                {
                    mp[b + 1] = mx;

                    set.insert(b + 1 - mx);
                }
            }
        }

        if (set.empty())
            std::cout << -1 << std::endl;
        else
            std::cout << i + *(set.begin()) << std::endl;

        //std::cerr << "DEBUG" << std::endl;
        /*for (auto x : mp)
            std::cerr << x.first << ' ' << x.second << std::endl;*/
    }

    return 0;
}

Measured memory_bytes: 22336
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9+7

p, q = [0]*N, [0]*N
for i in range(N):
    for j in range(i):
        if A[i] > A[j]:
            p[i] += 1
            q[i] += 1
    for j in range(i+1,N):
        if A[i] > A[j]:
            p[i] += 1

ans = 0
if K % 2 == 0:
    k = ((K//2)*(K+1)) % MOD
else:
    k = (K*((K+1)//2)) % MOD
for i in range(N):
    ans = (ans + (((k * p[i]) % MOD - (K*q[i]) % MOD) % MOD)) % MOD
print(ans)

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

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int r, D, x;
	cin >> r >> D>>x;
	rep(i,0,10){
		x = r*x-D;
		cout << x << endl;
	}
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}


Measured memory_bytes: 256
from collections import defaultdict

N, M, K = map(int, input().split())
friends = defaultdict(list)
blocked = defaultdict(list)

for i in range(M):
    a, b = map(int, input().split())
    friends[a - 1].append(b - 1)
    friends[b - 1].append(a - 1)
for j in range(K):
    c, d = map(int, input().split())
    blocked[c - 1].append(d - 1)
    blocked[d - 1].append(c - 1)


class UF:
    def __init__(self, node_id):
        self.node_id = node_id
        self._root = self
        self._size = 1

    @property
    def root(self):
        p = self._root
        while p is not p._root:
            p = p._root
        q = self
        while q._root is not p:
            r = q._root
            q._root = p
            q = r
        return p

    @property
    def size(self):
        return self.root._size

    def merge(self, other):
        if self.root.node_id == other.root.node_id:
            return self.root
        elif self.root.node_id < other.root.node_id:
            self.root._size += other.root._size
            other._root = self.root
            return self.root
        else:
            other.root._size += self.root._size
            self._root = other.root
            return other.root


sets = [UF(i) for i in range(N)]
visited = set()
for i in range(N):
    if i in visited:
        continue
    r = sets[i]
    stack = [(i, None)]
    while stack:
        j, parent_id = stack.pop()
        if j in visited:
            continue
        visited.add(j)
        for k in friends[j]:
            if k != parent_id:
                r = r.merge(sets[k])
                if k not in visited:
                    stack.append((k, j))

ans = []
for i in range(N):
    res = sets[i].size - len(friends[i]) - 1
    root_id = sets[i].root.node_id
    for b in blocked[i]:
        if sets[b].root.node_id == root_id:
            res -= 1
    ans.append(res)
print(*ans)


Measured memory_bytes: 124248
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll h, w;
    cin>>h>>w;
    vector<string> s(h);
    for(ll i=0;i<h;++i){
        cin>>s[i];
    }

    ll l[h][w], r[h][w], u[h][w], d[h][w];
    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            if(s[i][j] == '.'){
                if(j == 0){
                    l[i][j] = 1;
                }else{
                    l[i][j] = l[i][j-1] + 1;
                }
            }else if(s[i][j] == '#'){
                l[i][j] = 0;
            }
        }
        for(ll j=w-1;j>=0;--j){
            if(s[i][j] == '.'){
                if(j == w-1){
                    r[i][j] = 1;
                }else{
                    r[i][j] = r[i][j+1] + 1;
                }
            }else if(s[i][j] == '#'){
                r[i][j] = 0;
            }
        }
    }
    for(ll j=0;j<w;++j){
        for(ll i=0;i<h;++i){
            if(s[i][j] == '.'){
                if(i == 0){
                    u[i][j] = 1;
                }else{
                    u[i][j] = u[i-1][j] + 1;
                }
            }else if(s[i][j] == '#'){
                u[i][j] = 0;
            }
        }
        for(ll i=h-1;i>=0;--i){
            if(s[i][j] == '.'){
                if(i == h-1){
                    d[i][j] = 1;
                }else{
                    d[i][j] = d[i+1][j] + 1;
                }
            }else if(s[i][j] == '#'){
                d[i][j] = 0;
            }
        }
    }

    ll ans = 0;
    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            ll sum = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3;
            ans = max(ans, sum);
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = INF + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int n;
	cin >> n;
	vector<int>a(n);
	for(int i=0; i<n ;i++)  cin >> a[i];
	map<int,int>m;
	int ans = -1;
	for(int i=0 ; i<n ; i++)
	{
		if(a[i] == 1)
			m[1] = 1 , ans = 1;
		else if(m[a[i] -1] == 1)
			m[a[i]] = 1 , ans =max(ans,a[i]);
	}
	
	if(ans !=-1)    ans = n - ans;
	cout << ans;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) {
    cout << "a < b" << endl;
  } else if (a > b) {
    cout << "a > b" << endl;
  } else {
    cout << "a == b" << endl;
  }
}



Measured memory_bytes: 3076