akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
typedef pair<ll, ll> pll;

const int mod = 1000000007;

ll modpow(ll x, ll y){
    ll res = 1;
    for (ll i=0; i<y; i++){
        res = res * x % mod;
    }
    return res;
}

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

    ll ans = modpow(10, n) - 2 * modpow(9, n) % mod + modpow(8, n);
    ans %=mod;
    ans = (ans + mod) % mod;
    cout << ans << endl;
}


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

long long n;
long long a[200010];

int main()
{
    cin>>n;
    for(long long i=1;i<=n;i++) scanf("%I64d",&a[i]);
    long long l=1,r=1,sum=0,num=0,Xor=0,ans=0;
    while(l<=n){
        while(sum==Xor&&r<=n){
            sum+=a[r];
			Xor^=a[r];
			r++;
			num++;
        }
        if(sum==Xor) ans+=num--;
        else ans+=--num;
        r--;
        sum-=a[r];
        Xor^=a[r];
        l++;
        sum-=a[l-1];
        Xor^=a[l-1];
		num--;
    }
	cout<<ans<<endl;
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T& n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<vector<int>> table;
  int n,w,vn,wn;
  cin >> n >> w;
  table.resize(w+1);
  rep(i,w+1){
    table[i].resize(n+1,0);
  }
  rep(i,n){
    cin >> vn >> wn;
    rep(j,w+1){
      if(wn <= j ){
        int v = table[j][i] ;
        if(v < table[j-wn][i]+vn){
          v = table[j-wn][i]+vn ;
        }
        table[j][i+1] = v;
      }
      else{
        table[j][i+1] = table[j][i];
      }
    }
  }
  /*rep(i,n+1){
    rep(j,w+1){
      cout << table[j][i] << " " ;
    }
    cout << endl;
  }*/
  cout << table[w][n] << endl;
  return 0;

}

Measured memory_bytes: 7064
@local = [0,1,0,1,0,nil,1]
def localq(x)
    puts "#{x} => #{@local[x]}"
    abort "invalid" unless 0<=x&&x<@local.size
    return @local[x]
end


def query(x)
    #return localq(x) # localtest!!!
    
    STDOUT.puts x
    STDOUT.flush
    s = gets.chomp
    s == 'Vacant' ? nil : s == 'Male' ? 0 : 1
end

N = gets.to_i
#N = @local.size

abort unless N.odd?




h = query(0)
exit if !h

y = (0..N/2).bsearch{|x|
    r = query(x*2)
    exit if !r
    h != r
}

y = y*2-1
exit if !query(y)

1.upto(99) do |i|
    exit if !query((y+i)%N)
    exit if !query((y-i)%N)
end

Measured memory_bytes: 2384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
using pp=pair<int,pair<int,int>>;
#define MOD 1000000007
#define INF 1000000000

int main(){
  int N;
  cin>>N;
  cout<<(N-1)/2<<endl;
}


Measured memory_bytes: 3600
from sys import stdin
 
n = int(stdin.readline().rstrip())
x = [float(x) for x in stdin.readline().rstrip().split()]
y = [float(x) for x in stdin.readline().rstrip().split()]
 
def minkowski_dist(x, y, p="INF"):
    if p == "INF":
        return max([abs(x[i]-y[i]) for i in range(n)])
    elif isinstance(p, int):
        return (sum([(abs(x[i]-y[i]))**p for i in range(n)]))**(1/p)
 
print(minkowski_dist(x, y, 1))
print(minkowski_dist(x, y, 2))
print(minkowski_dist(x, y, 3))
print(minkowski_dist(x, y))


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

typedef long long ll;
const ll MOD = 1000000007;

int main(){
	static ll n,m;
	static ll x[100010],y[100010];
	scanf("%lld%lld",&n,&m);
	for(int i = 0 ; i < n ; i ++){
		scanf("%lld",&x[i]);
	}
	for(int i = 0 ; i < m ; i ++){
		scanf("%lld",&y[i]);
	}
	
	ll X = 0, Y = 0;
	for(int i = 0 ; i+1 < n ; i ++){
		ll t = (i+1)*(n-(i+1));
		t %= MOD;
		t *= x[i+1]-x[i];
		X += t; X %= MOD;
	}
	for(int i = 0 ; i+1 < m ; i ++){
		ll t = (i+1)*(m-(i+1));
		t %= MOD;
		t *= y[i+1]-y[i];
		Y += t; Y %= MOD;
	}
	cout << (X*Y)%MOD << endl;
}

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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;

    vector<unsigned long long> A(90);
    A.at(0) = 2;
    A.at(1) = 1;
    for (size_t i = 2; i < 90; i++)
    {
        A.at(i) = A.at(i-1)+A.at(i-2);
    }
    cout << A.at(N) << endl;

    return 0;
}

Measured memory_bytes: 3604
# -*- coding: utf-8 -*-

N,Y = map(int, input().split())

for i in range(N+1):
    for j in range(N+1-i):
        output = 10000 * i + 5000 * j + 1000 * (N-i-j)
        if output == Y:
            print(i,j,N-i-j)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 3064
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math


def get_int():
    return int(stdin.readline().strip())


def get_tuple():
    return map(int, stdin.readline().split())


def get_list():
    return list(map(int, stdin.readline().split()))



def solve():
    n,m = get_tuple()
    print(n*m)



def main():
    solve()


TestCases = False

if TestCases:
    for i in range(get_int()):
        main()
else:
    main()



Measured memory_bytes: 9660
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

bool sw[11];
int k[11];
int s[11][11];
int p[11];
int ans = 0;
int N, M;

bool check()
{
    int i, j, cnt;
    for(i = 1; i <= M; i++)
    {
        cnt = 0;
        for(j = 1; j <= k[i]; j++)
        {
            if(sw[s[i][j]])
                cnt++;
        }
        if(cnt % 2 != p[i])
            return false;
    }
    return true;
}

void f(int idx)
{
    if(idx == N + 1)
    {
        if(check())
            ans++;
        return;
    }
    else
    {
        sw[idx] = false;
        f(idx+1);
        sw[idx] = true;
        f(idx+1);
    }
}

int main()
{
    cin >> N >> M;
    int i, j;
    for(i = 1; i <= M; i++)
    {
        cin >> k[i];
        for(j = 1; j <= k[i]; j++)
        {
            cin >> s[i][j];
        }
    }
    for(i = 1; i <= M; i++)
        cin >> p[i];
    
    f(1);
    cout << ans;
    
    return 0;
}


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

int main(){
	int a,b;

	for (a=1; a<=9; a++){
		for (b=1; b<=9; b++){
			cout << a << 'x' << b << '=' << a * b << '\n';
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#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 int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  int d = b / a;
  if (c <= d) {
    cout << c << endl;
  } else {
    cout << d << endl;
  }

  return 0;
}


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

using namespace std;

int main(){
  int n;
  int a[100]={};

  cin >> n;

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

  cout << abs(a[0]-a[n-1]) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll p=pow(10,9)+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
    x = x % p;  
   while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,j,i,k,m1,y1,m2,y2;
    string s,t;
    cin>>s;
    for(i=0;i<s.length();i++)
    cout<<'x';

    return 0;
    
}
    


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;
using P = pair<int,int>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k, a, b;
  cin >> k >> a >> b;
  int m = k;
  int j = 0;
  while(k <= b) {
    if(k >= a && k <= b) {
      j = 1;
      break;
    } else {
      k += m;
    }
  }
  if(j) puts("OK");
  else puts("NG");
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;


int main() {
	string str;
	cin >> str;
	int cnt = str.sz - 2;
	if (str[0] == str[str.sz - 1])
		cnt--;
	if (cnt & 1)
		cout << "First";
	else
		cout << "Second";
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <functional>
#include <string>
 
using namespace std;

int main()
{
    int N,K;
    cin >> N >> K;
    int h;
    int result = 0;
    for (int i=0; i<N; i++) {
        cin >> h;
        if (K <= h) {
            result++;
        }
    }
    cout << result;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    if(10%p==0){
    	ll ans=0;
    	for(int i=0;i<n;i++)if((s[i]-'0')%p==0)ans += i+1;
    	cout << ans << endl;
    	return 0;
    }
    /*ll a[n+1];
    a[0]=0;
    for(int i=0;i<n;i++){
    	a[i+1]=(a[i]*10+(s[i]-'0'))%p;
    }
    ll num[p];
    ll ans=0;
    memset(num,0,sizeof(num));
    for(int i=0;i<=n;i++){
    	ans+=num[a[i]];
    	num[a[i]]++;
    }
    cout << ans << endl;*/


    ///////


    ll a[n],b=(s[n-1]-'0')%p,c=10;a[n-1]=b;
    for(int i=s.length()-2;i>=0;i--){
        (b+=c*(s[i]-'0'))%=p;
        a[i]=b;
        (c*=10)%=p;
    }
    ll num[p];
    memset(num,0,sizeof(num));
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=num[a[i]];
        num[a[i]]++;
    }
    ans+=num[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2196
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;

	auto a = S[0..2].to!long;
	auto b = S[2..$].to!long;
	bool am, bm;
	if (a != 0 && a <= 12)
	{
		am = true;
	}
	if (b != 0 && b <= 12)
	{
		bm = true;
	}
	if (am && bm)
	{
		writeln("AMBIGUOUS");
	}
	else if (am)
	{
		writeln("MMYY");
	}
	else if (bm)
	{
		writeln("YYMM");
	}
	else
	{
		writeln("NA");
	}

	stdout.flush();
	debug readln();
}

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 pair<int, int> P;

P f(int x) {
  int a = x%10;
  int b = 0;
  while (x){
    b = x;
    x /= 10;
  }
  return P(a,b);
}

int main(){
  int n;
  cin >> n;
  map<P,int> freq;
  for (int i = 1; i <= n;i++){
  P p = f(i);
    freq[p]++;
  }
  
  ll ans = 0;
  for (int i = 1; i <= n;i++){
  P p = f(i);
  P q(p.second, p.first);
    ans += freq[q];
  }
  cout << ans << endl;
}

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



int main()
{
    int n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n) cin >> c[i];
    
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    vector<ll> dp1(n + 1, 0);
    vector<ll> dp2(n + 1, 0);

    int j = 0;
    rep(i, 0, n)
    {
        for(; j < n; j++)
            if (a[j] < b[i]) dp1[i]++;
            else break;
    }
    rep(i, 1, n)
        dp1[i] += dp1[i - 1];
    
    j = 0;
    rep(i, 0, n)
    {
        for(; j < n; j++)
            if (b[j] < c[i]) dp2[i] += dp1[j];
            else break;
    }
    rep(i, 1, n)
        dp2[i] += dp2[i - 1];
    
    ll ans = 0;
    rep(i, 0, n)
        ans += dp2[i];

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

Measured memory_bytes: 4224
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
t = [0] + list(map(int, input().split()))
m = int(input())

ans = sum(t)
for _ in range(m):
    p, x = map(int, input().split())
    print(ans - (t[p] - x))


Measured memory_bytes: 62276
#include<iostream>

using namespace std;

int main(){
  while(true){
  int aa[10] = {0};
  int ans = 0, sum = 0;
  for(int i = 0; i < 10; i++)
    cin >> aa[i];
  if(!aa[0])
    break;
  for(int i = 1; i < 10; i++)
    sum += aa[i];
  ans = aa[0] - sum;
  cout << ans << endl;
}
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <math.h>

unsigned int factorial(unsigned int n){
    if (n==0) return 1;
    else return n*factorial(n-1);
}
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
using namespace std;

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

    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    for(int i=0;i<n;i++) cin>>c[i];

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans=0;
    for (int i=0;i<n;i++){
        ll Iter=lower_bound(a.begin(),a.end(),b[i])-a.begin();
        ll Iter2=c.end()-upper_bound(c.begin(),c.end(),b[i]);
        ans+=Iter*Iter2;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4584
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    key_words = [e[::-1] for e in ["dream", "dreamer", "erase", "eraser"]]

    target = input()[::-1]

    i = 0
    while True:
        matched_any = False
        for k in key_words:
            k_len = len(k)
            if k == target[i:i + k_len]:
                i += k_len
                matched_any = True
                break

        if not matched_any:
            print("NO")
            break

        if i == len(target):
            print("YES")
            break


Measured memory_bytes: 5452
/*bismillah ->                                                                                                         << Suirkhanov Meyirlan >>
  GL HF


                                                                                                                      42

    bless my code =)
                                                                                                            NEVER FOLLOW YOUR RULES :D HAHAHAHA
*/


///scanf ("%d%d", &x, &y);
///printf("%d", &a)

#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));
#define pii pair < int , int >
#define pll pair < ll, ll >
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fast ios_base::sync_with_stdio();   cin.tie(0);   cout.tie(0);
#define randoperation srand(time(0));

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll N = 1e6 + 7;
const ld pi = 3.14159265359;
const int INF = 1e9 + 7;
const double eps = 1e-9;

const int xi[4] = {-1, 0, +1, 0};
const int yj[4] = {0, +1, 0, -1};
const int xxi[4] = {+1, 0, -1, 0};
const int yyj[4] = {0, -1, 0, +1};

ll n, m;

int main(){

  //freopen("bridge.in", "r", stdin);
  //freopen("bridge.out", "w", stdout);

  fast
  randoperation;

  ///           ||
  ///start here \/

  cin >> n >> m;

  if(n == 2 && m == 2){
    cout << 1;
  }
  else{
    cout << (n * m) - m - n + 1;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=998244353;
 int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
   else
     return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;
}
int main(){
  int64_t N,M,K;
  cin>>N>>M>>K;
  if(M==1){
  if(K==N-1)
    cout<<1<<endl;
    else
      cout<<0<<endl;
  }
  else{int64_t ans=0;int64_t a=1;int64_t b=f(M-1,N-1);int64_t c=f(M-1,mod-2);
  for(int i=0;i<=K;i++){
  ans=(ans+a*b)%mod;
    a=(a*(N-i-1))%mod;a=(a*f(i+1,mod-2))%mod;
    b=(b*c)%mod;
  }ans=(ans*M)%mod;
  cout<<ans<<endl;
      }
  return 0;
}

Measured memory_bytes: 3608
n,m = list(map(int,input().split()))
h = list(map(int,input().split()))
p = [[] for i in range(n)]
for i in range(m):
    a,b = list(map(int,input().split()))
    p[a-1].append(b-1)
    p[b-1].append(a-1)

ans=0
for i in range(n):
    flag = True
    for j in p[i]:
        if h[j]>=h[i]:
            flag = False
            break
    if flag:
        ans+=1
print(ans)

Measured memory_bytes: 29392
s = input().split()


flag = 0

if(s[0] == s[1]):
    if(s[0] != s[2]):
        print("Yes")
        flag = 1
        
if(s[1] == s[2]):
    if(s[0] != s[2]):
        print("Yes")
        flag = 1


if(s[2] == s[0]):
    if(s[1] != s[2]):
        print("Yes")
        flag = 1
        
if(flag == 0):
    print("No")

Measured memory_bytes: 3064
open System

[<EntryPoint>]
let main argv =
    let N = stdin.ReadLine() |> int

    let A = double N / 1.08
    let N1 = int (Math.Floor(A))
    let N2 = int (Math.Ceiling(A))

    let N3 = (N1 * 108) / 100
    let N4 = (N2 * 108) / 100

    if (N3 = N) then
        printfn "%d" N1
    else if (N4 = N) then
        printfn "%d" N2
    else
        printfn ":("
    0

Measured memory_bytes: 14040
#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, k;
    cin >> n >> k;
    int ans = 0;
    rep(i,n){
        int h;
        cin >> h;
        if(h >= k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{    
    string s;
    cin >> s;
    // s = "needed";
    int size_s = s.length();
    int sub_s, sub_e;
    sub_s = -1, sub_e = -1;
    // 1. 連続している文字があればok
    for(int i=0; i<size_s-1; ++i){
        if(s.substr(i, 1) == s.substr(i+1, 1)){
            sub_s = i+1;
            sub_e = i+2;
            break;
        } 
    }
    // 2. 1個間隔であればok
    for(int i=0; i<size_s-2; ++i){
        if(s.substr(i, 1) == s.substr(i+2, 1)){
            sub_s = i+1;
            sub_e = i+3;
            break;
        } 
    }

    // これらが無ければ十分不可能
    cout << sub_s << " " << sub_e << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    long int a[10000],i,j,x;
    for(i=0;i<10;i++)
    scanf("%ld",&a[i]);
    for(i=0;i<10;i++)
    {
        for(j=i+1;j<10;j++)
        {
            if(a[i]<a[j])
            {
                x=a[i];
                a[i]=a[j];
                a[j]=x;
            }
        }
    }
    for(i=0;i<3;i++)
        {
        printf("%ld",a[i]);
        printf("\n");
        }
    return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    int n;
    cin >> n;
    vector<P> a(n);
    REP(i, n) {
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(ALL(a));
    reverse(ALL(a));

    /* 活発度の高い順に左端 or 右端に詰めていく */
    /* 左端に詰める場合と右端に詰める場合とは動的計画法で試していく */
    vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));    /* dp[i][j]: 左にi人、右にj人詰めたときのうれしさの最大スコア */

    REP(i, n) REPN(j, 0, n-i) {
        /* 左につめる */
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + a[i+j].first * abs(a[i+j].second - i));

        /* 右につめる */ 
        dp[i][j+1] = max(dp[i][j+1], dp[i][j] + a[i+j].first * abs(a[i+j].second - (n - 1 - j)));
    }

    ll ans = 0;
    REP(i, n+1) {
        ans = max(ans, dp[i][n-i]);
    }

    cout << ans << endl;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
vll a,b,c;
priority_queue<lli> qp;
priority_queue<lli,vll,greater<lli>> pq;
vll r,l;

int main(){
  cin >> n;
  a = b = c = vll(n);
  for(lli i = 0;i < n;i++) cin >> a[i];
  for(lli i = 0;i < n;i++) cin >> b[i];
  for(lli i = 0;i < n;i++) cin >> c[i];
  r = l = vll(n+1);
  r[0] = accumulate(a.begin(),a.end(),0ll);
  l[n] = accumulate(c.begin(),c.end(),0ll);
  for(lli i = 0;i < n;i++) pq.push(a[i]);
  for(lli i = 0;i < n;i++) qp.push(c[i]);
  for(lli i = 0;i < n;i++){
    pq.push(b[i]);
    r[i+1] = r[i]+b[i]-pq.top();
    pq.pop();
  }
  for(lli i = n-1;i >= 0;i--){
    qp.push(b[i]);
    l[i] = l[i+1]+b[i]-qp.top();
    qp.pop();
  }
  for(lli i = 0;i <= n;i++) r[i] -= l[i];
  cout << *max_element(r.begin(),r.end()) << endl;
  return 0;


}


Measured memory_bytes: 6516
#include <bits/stdc++.h>
#define PI 3.141592653589
using namespace std;
int n, L;
double t[3010];
int main() {
    scanf("%d%d", &n, &L);
    for (int i = 1; i <= n; i++) scanf("%lf", t + i), t[i] /= L;
    double ansx = 0, ansy = 0;
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++) {
            ansx += (j - i - 1) * cos((t[i] + t[j]) * PI + PI);
            ansx += (n - j + i - 1) * cos((t[i] + t[j]) * PI);
            ansy += (j - i - 1) * sin((t[i] + t[j]) * PI + PI);
            ansy += (n - j + i - 1) * sin((t[i] + t[j]) * PI);
        }
    double x = 1. * n * (n - 1) * (n - 2) / 6;
    return printf("%.10f %.10f\n", ansx / x, ansy / x), 0;
}

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

int main(){
	const int INF=1000000000;
	int n,c;
	int dp[2][5000+2][2];
	for(int i=0;i<2;i++)for(int j=0;j<5002;j++){dp[i][j][0]=INF; dp[i][j][1]=INF;}
	dp[1][1][0]=0;
	dp[1][0][1]=0;
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		int s=i%2,t=1-s;
		scanf("%d",&c);
		int m=min(i,n/2);
		for(int j=0;j<=m;j++){
			if(j==0)dp[s][j][0]=INF;
			else dp[s][j][0]=min(dp[t][j-1][0],dp[t][j-1][1]+c);
			dp[s][j][1]=min(dp[t][j][0]+c,dp[t][j][1]);
		}
	}
	printf("%d\n",min(dp[0][n/2][0],dp[0][n/2][1]));
}

Measured memory_bytes: 1268
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d) {
		cout << "Left";
	}
	else if (a + b == c + d) cout << "Balanced";
	else cout << "Right";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <sys/time.h>

#define N	200000
#define M	200000
#define INF	0x3f3f3f3f

int min(int a, int b) { return a < b ? a : b; }

unsigned int X;

void srand_() {
	struct timeval tv;

	gettimeofday(&tv, NULL);
	X = tv.tv_sec ^ tv.tv_usec;
	if (X % 2 == 0)
		X++;
}

int rand_() {
	return (X *= 3) >> 1;
}

int ll[M], rr[M];

void sort(int *hh, int l, int r) {
	while (l < r) {
		int i = l, j = l, k = r, h = hh[l + rand_() % (r - l)], tmp;

		while (j < k)
			if (ll[hh[j]] == ll[h])
				j++;
			else if (ll[hh[j]] < ll[h]) {
				tmp = hh[i], hh[i] = hh[j], hh[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = hh[j], hh[j] = hh[k], hh[k] = tmp;
			}
		sort(hh, l, i);
		l = k;
	}
}

int n;

void update(int *st, int i, int x) {
	for (i += n; i > 0; i >>= 1)
		st[i] = min(st[i], x);
}

int query(int *st, int l, int r) {
	int x = INF;

	for (l += n, r += n; l <= r; l >>= 1, r >>= 1) {
		if ((l & 1) == 1)
			x = min(x, st[l++]);
		if ((r & 1) == 0)
			x = min(x, st[r--]);
	}
	return x;
}

int main() {
	static int pp[N], hh[M], st1[N * 2], st2[N * 2];
	int m, h, i, d, ans;

	srand_();
	scanf("%d", &n);
	d = 0;
	for (i = 0; i < n; i++) {
		scanf("%d", &pp[i]);
		if (pp[i] == 0)
			pp[i] = 1;
		else
			pp[i] = -1, d++;
	}
	for (i = 1; i < n; i++)
		pp[i] += pp[i - 1];
	scanf("%d", &m);
	for (h = 0; h < m; h++) {
		scanf("%d%d", &ll[h], &rr[h]), ll[h]--, rr[h]--;
		hh[h] = h;
	}
	sort(hh, 0, m);
	memset(st1, 0x3f, n * 2 * sizeof *st1);
	ans = 0;
	for (h = 0; h < m; h++) {
		int h_ = hh[h], x = min(query(st1, ll[h_], rr[h_]), ll[h_] == 0 ? 0 : query(st2, 0, ll[h_] - 1) - pp[ll[h_] - 1]) + pp[rr[h_]];

		ans = min(ans, x);
		update(st1, rr[h_], x - pp[rr[h_]]);
		update(st2, rr[h_], x);
	}
	ans += d;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 7960
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<stack>
#include<map>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<utility>

using ULL = unsigned long long;
using LL = long long;
using String = std::string;
using Ints = std::vector<int>;
using Doubles = std::vector<double>;
using Bools = std::vector<bool>;
using Strings = std::vector<std::string>;
using ULLs = std::vector<ULL>;
using LLs = std::vector<LL>;

// pythonのdictionary相当
template <typename T1, typename T2>
using Dict = std::unordered_map<T1,T2>;



int main(void) {
    ULL N;
    std::cin >> N;

    Ints res;

    while(N>0.99){
        N--;
        res.push_back(N%26);
        N/=26.0;
    }

    for(auto it=res.rbegin();it!=res.rend();++it){
        std::cout << static_cast<char>(*it+'a');
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int A = V[0], B = V[1], T = V[2];
            Console.WriteLine((T / A) * B);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = INT32_MAX;
const ll INFL = INT64_MAX;
const int mod = 1e9 + 7;

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}
int dist[100003][3];

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > to(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    to[a].push_back(b);
  }
  int sv, tv;
  cin >> sv >> tv;
  --sv, --tv;
  rep(i, n) rep(j, 3) dist[i][j] = INF;
  queue<P> q;
  q.push(P(sv, 0));
  dist[sv][0] = 0;
  while (!q.empty()) {
    int v = q.front().first;
    int l = q.front().second;
    q.pop();
    for (int u : to[v]) {
      int nl = (l + 1) % 3;
      if (dist[u][nl] != INF) continue;
      dist[u][nl] = dist[v][l] + 1;
      q.push(P(u, nl));
    }
  }
  int ans = dist[tv][0];
  if (ans == INF)
    ans = -1;
  else
    ans /= 3;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6912
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

#define NMAX 500010

struct QUARR{
    int l;
    int r;
    int index;
    int type;
    int ans;
    bool operator<(QUARR q) const{
        if(type==1){
            if(q.r==r) return q.l>l;
            return q.r>r;
        }
        else{
            return q.index>index;
        }
    }
};

int ft_bit[NMAX];
void ft_add(int a,int w,int N){
    for(int x=a;x<=N;x+=x&-x){
        ft_bit[x]+=w;
    }
}

int ft_sum(int a){
    int ret=0;
    for(int x=a;x>0;x-=x&-x){
        ret+=ft_bit[x];
    }
    return ret;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    QUARR qu[NMAX];
    int last[NMAX];
    int c[NMAX];
    int N,Q;

    cin>>N>>Q;
    for(int i=1;i<=N;i++){
        cin>>c[i];
        last[i]=-1;
    }

    for(int i=1;i<=Q;i++){
        int l,r;
        cin>>l>>r;
        qu[i].l=l;
        qu[i].r=r;
        qu[i].index=i;
        qu[i].type=1;
        qu[i].ans=0;
    }

    sort(qu+1,qu+Q+1);

    for(int i=1;i<=qu[1].r;i++){
        if(last[c[i]]==-1){
            ft_add(i,1,N);
            last[c[i]]=i;
        }
        else{
            ft_add(last[c[i]],-1,N);
            ft_add(i,1,N);
            last[c[i]]=i;
        }
    }

    qu[1].ans=ft_sum(qu[1].r)-ft_sum(qu[1].l-1);
    qu[1].type=2;
    for(int i=2;i<=Q;i++){
        for(int j=qu[i-1].r+1;j<=qu[i].r;j++){
            if(last[c[j]]==-1){
                ft_add(j,1,N);
                last[c[j]]=j;
            }
            else{
                ft_add(last[c[j]],-1,N);
                ft_add(j,1,N);
                last[c[j]]=j;
            }
        }
        qu[i].ans=ft_sum(qu[i].r)-ft_sum(qu[i].l-1);
        qu[i].type=2;
    }

    sort(qu+1,qu+Q+1);

    for(int i=1;i<=Q;i++){
        cout<<qu[i].ans<<"\n";
    }
}


Measured memory_bytes: 35068
#include <stdio.h>
    #include <string.h>
                         
    int main (void){
        char S[200001], T[200001];
        int i = 0, ans = 0;
        scanf("%s %s", &S, &T);
        for(i = 0; i < strlen(S); i++){
           if(S[i] != T[i]){
              ans++;
            }
         }
        printf("%d\n", ans);
     }

Measured memory_bytes: 2476
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define mod 1000000007
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    vector<long long> h(n+k),cost(n+k,1000000000);
    rep(i,0,n-1)cin >> h[i];
    h[n] = 1000000000;

    cost[0] = 0;
    rep(i,0,n-2){
        rep(j,1,k)cost[i+j] = min(cost[i+j],cost[i]+abs(h[i]-h[i+j]));
    }

    int ans = cost[n-1];

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

#define lli long long int
#define ii pair<int, int>
#define ll pair<lli, lli>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define fi first
#define se second

using namespace std;

lli memo[105][100005];

int main() {
	lli n, k, a[105], bigmod = 1000000007, mini;
	scanf("%lld %lld", &n, &k);
	for (lli i = 1; i <= n; i++)
		scanf("%lld", &a[i]);
	memset(memo, 0, sizeof memo);
	for (int i = 0; i <= k; i++)
		memo[0][i] = 1;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j <= k; j++) {
			memo[i][j] = (memo[i][j] + memo[i][j - 1]) % bigmod;
			memo[i][j] = (memo[i][j] + memo[i - 1][j]) % bigmod;
			mini = j - a[i];
			if (mini > 0)
				memo[i][j] = (memo[i][j] - memo[i - 1][mini - 1] + bigmod) % bigmod;
		}
	mini = (memo[n][k] - memo[n][k - 1] + bigmod) % bigmod;
	printf("%lld\n", mini);
	return 0;
}

Measured memory_bytes: 82304
# Problem B - Collatz Problem

# input process
s = int(input())
min_m = 1
number_queue = []
number_queue.append(s)

# search process
while True:
    min_m += 1
    if s%2==0:
        s = s / 2
    else:
        s = 3 * s + 1

    if s in number_queue:
        break

    number_queue.append(s)

# output process
print(min_m)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int h, n;
vector<pair<int, int>> a;
vector<int> memo;
int solve(int x) {
	if (x <= 0) {
		return 0;
	}
	if (memo[x] != -1) {
		return memo[x];
	}
	int mn = inf;
	for (int i = 0; i < n; ++i) {
		mn = min(mn, solve(x - a[i].first) + a[i].second);
	}
	memo[x] = mn;
	return memo[x];
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	cin >> h >> n;
	a.resize(n);
	memo.resize(h + 1, -1);
	int mx = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i].first >> a[i].second;
		mx = max(mx, a[i].first);
	}
	cout << solve(h) << '\n';
	return 0;
}


Measured memory_bytes: 768
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).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>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n;cin>>n;
    string s;cin>>s;

    ll cnt=0,add=0;
    rep(i,n){
        if(s[i]==')')++cnt;
        else --cnt;
        chmax(add,cnt);
    }

    rep(i,add)s='('+s;
    rep(i,add-cnt)s+=')';
    cout<<s<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;

namespace ConsoleApp2
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<int> Slist() { return new List<int>(ReadLine().Split().Select(int.Parse)); }
        static void Main(string[] args)
        {
            var LR = Sarray();
            var L = LR[0];
            var R = LR[1];
            R = Math.Min(R, L + 4038);
            long ans = 2018;
            for(long i=L;i<=R;i++)
            {
                for(long j=i+1;j<=R;j++)
                {
                    long x = i * j % 2019;
                    ans = Math.Min(ans, x);
                }
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,m; cin >> n >> m;
    // 1 → x → n と動くとする
    VB s(200050,0) , t(200050,0);
    REP(i,m){
        int a,b; cin >> a >> b;
        if(a==1) s[b] = 1;
        if(a==n) t[b] = 1;
        if(b==1) s[a] = 1;
        if(b==n) t[a] = 1;
    }
    REP(i,200050) if(s[i]&&t[i]){out("POSSIBLE"); return 0;}
    out("IMPOSSIBLE");

    return 0;
}

Measured memory_bytes: 256
z[4000],*a=z,*b=z+2000,m,i,j;main(n){for(;scanf("%d",&n),i=n;printf("%d\n",m))for(memset(a,m=0,8e3);i--;j=a,a=b,b=j)for(j=scanf(" ");j++<n;)m=fmax(m,b[j]=getchar()-42?1+fmin(fmin(b[j-1],a[j-1]),a[j]):0);}

Measured memory_bytes: 0
n = int(input())
s = list(input())

r = s.count('R')
g = s.count('G')
b = s.count('B')

cnt = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j - i
        if 2 <= k <= n-1:
            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                cnt += 1
        else:
            break
print(r*g*b - cnt)

Measured memory_bytes: 9092
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
print(Counter(rs())['1'])

Measured memory_bytes: 62956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
ll ans[55],c[55],d[55],f[55][10005];
struct E{ll to,a,b;};
struct P{ll t,pos,s;};
bool operator <(const P &a,const P &b){return a.t>b.t;}
vector<E>edge[55];
priority_queue<P> q;
int main(){
    ll n,m,k,sum=0;
    cin>>n>>m>>k;
    rep(1,i,m+1){
        ll u,v,x,y;
        cin>>u>>v>>x>>y;
        edge[u].push_back({v,x,y});
        edge[v].push_back({u,x,y});
    }
    rep(1,i,n+1){
        cin>>c[i]>>d[i];
        c[i]=min((ll)5000,c[i]);
    }
    k=min((ll)5000,k);
    q.push({1,1,k});
    while(!q.empty()&&sum<n){
        ll x=q.top().t,p=q.top().pos,num=q.top().s;q.pop();
        //cout<<"x="<<x<<"p="<<p<<endl;
        if(f[p][num])continue;
        f[p][num]=x;
        //cout<<"x="<<x<<"p="<<p<<endl;
        if(!ans[p])ans[p]=x,sum++;
        //cout<<"ans[2]="<<ans[2]<<endl;
        for(E i:edge[p]){
            if(!f[i.to][num-i.a]&&num>=i.a)q.push({x+i.b,i.to,num-i.a});
            if(num+c[p]<=5000)q.push({x+d[p],p,num+c[p]});
        }
    }
    rep(2,i,n+1){
        cout<<ans[i]-1<<endl;
    }
}

Measured memory_bytes: 29824