akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll now = 0;
  ll n;cin>>n;
  string s;cin>>s;
  ll fr = 0,re = 0;
  for(auto c:s){
    if(c == '('){
      now++;
    }else{
      now--;
      if(now < 0){
	fr++;
	now = 0;
      }
    }
  }
  while(fr--)cout<<'(';
  cout<<s;
  while(now--)cout<<')';
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
 * Author : Sadi
 * Sat 18/07/2020
 * 18:35:08.70
 */
#include <bits/stdc++.h>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    vector<int> ans;
    ans.push_back(v[0]);
    for(int i = 1; i < n; ++i) {
        if(v[i] < ans.back()) {
            ans.push_back(v[i]);
        }
    }
    cout << ans.size() << "\n";
    return 0;
}


Measured memory_bytes: 4976
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();

        if(K<=(B-A+1)/2){
            for(int i=A; i<=A+K-1; i++){
                System.out.println(i);
            }
            for(int i=B-K+1; i<=B; i++){
                System.out.println(i);
            }
        }
        else{
            for(int i=A; i<=B; i++){
                System.out.println(i);
            }
        }
    } 
}

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

int main() {
    int n, m; cin >> n >> m;
    map<int, map<int, bool>> possible;
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        possible[a][b] = possible[b][a] = true;
    }

    for (int i = 2; i < n; ++i) {
        if (possible[1][i] && possible[i][n]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;
}



Measured memory_bytes: 50376
s = [int(x) for x in input()]
n = len(s)
result = 0

for i in range(2**(n-1)):
  sum = 0
  tmp = s[0]
  for j in range(n-1):
    if (i >> j) % 2 == 1:
      sum += tmp
      tmp = s[j+1]
    else:
      tmp = tmp * 10 + s[j+1]
  sum += tmp
  result += sum

print(result)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	string s;
	cin>>s;
	ll ans=0,cnt=0;
	for(int i=0;i<s.size();i++){
		cnt=0;
		for(int j=i;j<s.size();j++){
			if(s[j]=='A'||s[j]=='T'||s[j]=='G'||s[j]=='C')cnt++;
			else{
				ans=max(ans,cnt);
				break;
			}
		}
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include  <stdio.h>

int main()
{
	int n;
	int u2, d2;

	scanf("%d", &n);
	u2 = n / 100;
	d2 = n % 100;

	if ((u2 == 0 || u2 >= 13) && (d2 >= 1 && d2 <= 12))
		printf("YYMM");
	else if ((u2 >= 1 && u2 <= 12) && (d2 == 0 || d2 >= 13))
		printf("MMYY");
	else if ((u2 >= 1 && u2 <= 12) && (d2 >= 1 && d2 <= 12))
		printf("AMBIGUOUS");
	else if ((u2 == 0 || u2 >= 13) && (d2 == 0 || d2 >= 13))
		printf("NA");
		
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <set>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int n;
    cin >> n;
    set<string> flute;
    REP(i, n) {
        string tmp;
        cin >> tmp;
        flute.insert(tmp);
    }

    cout << flute.size() << '\n';
    return 0;
}


Measured memory_bytes: 19220
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 X, Y;
  cin >> X >> Y;
  for (i64 i = 0; i <= X; i++)
  {
    if (i * 2 + (X - i) * 4 == Y)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    vector<int> A(3);
    rep(i, 0, 3) cin >> A[i];
    int K; cin >> K;
    sort(ALL(A));
    while(K--){
        A[2] *= 2;
    }
    cout << accumulate(ALL(A), 0) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define scout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int n; cin >> n;
	cout << (double)(n - n / 2) / (double)n << endl;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
int main(){
 int M, S, J, I;
 int A, B;
  cin >> A >> B;
  int c = 0;
   for(int i = A; i <= B; i++){
    M = i / 10000;
    I = i % 10;
    S = i % 10000 / 1000;
    J = i % 100 / 10;
    if ( M == I && S == J){
      c++;
    }
   }
  cout << c << endl;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
    int k; cin >> k;
    int odds = 0, even = 0;
    for (int i = 1; i <= k; i++) {
        if (i % 2 == 0) even++;
        else odds++;
    }
    cout << odds * even << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
#define md 1000000007ll
#define mx 200000
ll fac[mx+2];
ll in[mx+2];

ll ncr(ll n, ll r){
    ll x = 1;
    for(ll i = 1;i<=r;i++){
        x = (x * mdINV(i, md))%md;
    }

    for(ll i = (n-r + 1); i <= n; i++){
        x = ( x* i) % md;
    }
    return x;    
}

int main(){
    // fac[0] = 1;
    // in[0] = mdINV(fac[0], md);
    // for(int i = 1;i<=mx;i++){
    //     fac[i] = fac[i-1 ] * i;
    //     fac[i] %= md;
    //     in[i] = mdINV(fac[i], md);
    // }

  ll n, a,b;
  L3(n,a,b);
  ll res = BM(2ll, n, md);

   res -= (1 + ncr(n,a) + ncr(n,b));

 res = (res % md + md) % md;

//   ll ans = (res * mdINV(n, md) ) % md;
//   if( a!=b){
//       ans = (ans * 2ll)%md;
//   }

  
//   res -=1;
//   res -= ans;
//   res = (res % md + md)% md;

  cout<<res<<endl;


    return 0;
}

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

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] A = Console.ReadLine().Split(' ').Select(x =>int.Parse(x)).ToArray();

            Console.WriteLine($"{A[0]-A[1]+1}");
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13396
#include<cstdio>
#include<iostream>
#include<queue>
#include<deque> 
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#define ll long long
#define inf 9999999999
#define mod 1000000007
using namespace std;
string a;
int main()
{
	while(cin >> a)
	{
		int l = a.size();
		if(l % 2 == 1)
			l --;
		else
			l -= 2;
		for(;l >= 0;l -=2)
		{
			int flag = 1;
			for(int i = 0;i < l / 2;i ++)
			{
				if(a[i] != a[i + l / 2])
				{
					flag = 0;
					break;
				}	
			}
			if(flag == 1)
			{
				cout << l << endl;
				break;
			}
		} 
	}
	return 0;
} 

Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  auto s=readln.chomp.to!(char[]);
  if(s.count("AC")) writeln("Yes");
  else writeln("No");
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 256
/***************************************************
 * Problem Name : C - Snack.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2019-12-22
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    ll a,b;
    cin >> a >> b;
    ll gc = __gcd(a,b);
    //~ cout << gc << "\n";
    cout << a*b/gc << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String name[]=new String[9];
		int n[]=new int[9];
		int c[]=new int[9];
		for(int i=0;i<9;i++){
			name[i]=sc.next();
			int temp1=sc.nextInt();
			int temp2=sc.nextInt();
			n[i]=temp1+temp2;
			c[i]=temp1*200+temp2*300;
		}
		for(int i=0;i<9;i++){
			System.out.println(name[i]+" "+n[i]+" "+c[i]);
		}
	}
}

Measured memory_bytes: 12000
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double x2 = sc.nextDouble();
        double y2 = sc.nextDouble();
  	    System.out.println(Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)));
    }
}


Measured memory_bytes: 28136
#include <stdio.h>
 
int main(){
    int y,m,d,num;
 
    while(scanf("%d %d %d",&y,&m,&d) != EOF){
        num = y*10000+m*100+d;
        if(num < 18680908){
            printf("pre-meiji\n");
        }else if(num < 19120730){
            printf("meiji %d %d %d\n",y-1867,m,d);
        }else if(num < 19261225){
            printf("taisho %d %d %d\n",y-1911,m,d);
        }else if(num < 19890108){
            printf("showa %d %d %d\n",y-1925,m,d);
        }else{
            printf("heisei %d %d %d\n",y-1988,m,d);
        }
    }
 
    return 0;
}


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

using namespace std;

int main(){
	int n,k;
	vector<int> ans;

	cin >> n >> k;

	while(k--){
		int x,y;
		cin >> x >> y;

		int h = min(x,n-x+1);
		int w = min(y,n-y+1);

		if(h > w){
			ans.push_back((w-1)%3+1);
		}
		else{
			ans.push_back((h-1)%3+1);
		}
	}
	int len = ans.size();

	for(int i=0;i<len;i++)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
 
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{
	fastio;
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	ll h,n;
	cin>>h>>n;
	vector<ii> v;
	ll lar=-1;
	for (int i = 0; i < n; ++i)
	{
		ll a,b;
		cin>>a>>b;
		lar = max(lar, a);
		v.push_back({a, b});
	}
	ll ori=h;
	h=h+lar;
	ll dp[n+1][h+1];

	for (int i=0; i<=h; i++) {
        dp[0][i] = INF; 
	}
  
    for (int i=1; i<=n; i++) {
        dp[i][0] = 0;
    }

    for (int i=1; i<=n; i++) 
    { 
        for (int j=1; j<=h; j++) 
        {
            if (v[i-1].F>j) {
                dp[i][j] = dp[i-1][j];
            }
            else {
                dp[i][j] = min(dp[i-1][j],
                     dp[i][j-v[i-1].F] + v[i-1].S); 
            }
        } 
    }
    ll ans=INT_MAX;
    for (int i = ori; i<=h; ++i)
    {
    	ans=min(ans, dp[n][i]);
    }
    cout<<ans;

	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int len = s.size();
    bool ok1=false,ok2=false;
    for(int i=0;i<len;i++){
        if(s[i]=='C')ok1=true;
        if(ok1&&s[i]=='F')ok2=true;
    }
    if(ok1&&ok2)cout<<"Yes"<<endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.buffer.readline

n, k = map(int, input().split())
XY = []
C = []
kouho = []
for i in range(n):
    x, y, c = map(int, input().split())
    XY.append((x, y))
    C.append(c)
    kouho.append(complex(x, y))
ct = 100
eps = 10 ** (-7)


class circle:
    def __init__(self, center, r):
        self.center = center
        self.r = r


def circle_cross(c1, c2):
    r1 = c1.r
    o1 = c1.center
    r2 = c2.r
    o2 = c2.center
    d = abs(o1 - o2)
    if d > r1 + r2:
        return 0, 0, 0
    elif r1 + r2 < d + eps and r1 + r2 > d - eps:
        # d==r1+r2
        return 1, (r2 * o1 + r1 * o2) / (r1 + r2), 0
    elif d < r1 + r2 and d > abs(r1 - r2):
        # abs(r1-r2)<d<r1+r2
        o21 = o2 - o1
        oh_nagasa = (d ** 2 + r1 ** 2 - r2 ** 2) / (2 * d)
        if oh_nagasa < eps:
            return 1, (r2 * o1 + r1 * o2) / (r1 + r2), 0
        oh = oh_nagasa * (o21 / d)
        housen = (o21 / d) * complex(0, 1)
        suisen = max(0, (r1 ** 2 - oh_nagasa ** 2) ** (1 / 2))
        ans1 = o1 + oh + housen * suisen
        ans2 = o1 + oh - housen * suisen
        return 2, ans1, ans2
    elif abs(r1 - r2) > d - eps and abs(r1 - r2) < d + eps:
        # d=abs(r1-r2)
        ans = (-r2 * o1 + r1 * o2) / (r1 - r2)
        return 1, ans, 0
    else:
        # d<abs(r1-r2)
        return 0, 0, 0


if n == 1:
    print(0)
    exit()
if k == 1:
    print(0)
    exit()

ok = 10 ** 10
ng = 0

while ct > 0:
    mid = (ok + ng) / 2
    kouho_temp = kouho[::]
    for i in range(n - 1):
        a, b = XY[i]
        p = C[i]
        A = circle(complex(a, b), mid / p)
        for j in range(i + 1, n):
            c, d = XY[j]
            q = C[j]
            B = circle(complex(c, d), mid / q)
            t1, t2, t3 = circle_cross(A, B)
            if t1 == 0:
                continue
            if t1 == 1:
                kouho_temp.append(t2)
            if t1 == 2:
                kouho_temp.append(t2)
                kouho_temp.append(t3)
    res = 0
    for z in kouho_temp:
        cnt = 0
        for i in range(n):
            x, y = XY[i]
            p = C[i]
            z1 = complex(x, y)
            if abs(z - z1) < mid / p + eps:
                cnt += 1
        res = max(cnt, res)
    if res >= k:
        ok = mid
    else:
        ng = mid
    ct -= 1


print(mid)


Measured memory_bytes: 55388
fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!

    var ans = s.toCharArray()
    var tOk = true
    for (i in s.length-t.length downTo 0) {
        ans = s.toCharArray()
        tOk = true
        for (j in t.indices) {
            if (s[i+j] == '?' || s[i+j] == t[j]) {
                ans[i+j] = t[j]
            } else {
                tOk = false
                break
            }
        }
        if (tOk) {
            println(ans.joinToString("").replace("?","a"))
            return
        }
    }
    println("UNRESTORABLE")
}


Measured memory_bytes: 37876
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

template<typename T>
vector<T> divisor(T n){
	vector<T> div;
	div.push_back(1);
	div.push_back(n);
	for(T i=2 ; i*i<=n ; ++i){
		if(n%i == 0){
			div.push_back(i);
			if(i*i!=n){
				div.push_back(n/i);
			}
		}
	}
	sort(all(div),greater<ll>());
	return div;
}

constexpr ll N_MAX = 500;
constexpr ll A_I_MAX = 1000000;
constexpr ll K_MAX = 1000000000;

ll N, K;
vector<ll> a;
void input() {
	scanf("%lld%lld", &N, &K);
	a.assign(N,0);
	rep(i,N)cin>>a[i];
}

void solve() {
	ll sum=accumulate(all(a),0LL);
	vector<ll> divlist=divisor(sum);
	rep(i,divlist.size()){
		ll div=divlist[i];
		vector<ll> amari(N,0);
		rep(j,N){
			amari[j]=a[j]%div;
		}
		sort(all(amari));
		ll amarisum=accumulate(all(amari),0LL);
		debug(amari);
		debug(amarisum);
		ll amaricount=amarisum/div;
		ll count=0;
		rep(k,amaricount){
			count+=div-amari[N-1-k];
		}
		if(count<=K){
			p(div);
			return;
		}
	}
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int dp[22][1<<22];

int solve(vector<vector<int > >& grid, int row, int womenAvailable, int N) {
    if(row > N) {
        if(womenAvailable) return 0;
        else return 1;
    }

    if(dp[row][womenAvailable] != -1) return dp[row][womenAvailable];

    int ans = 0;
    for(int col=0; col<N; col++) {
        if(grid[row][col+1] && ((1<<col) & womenAvailable) ) {
            ans = (ans + solve(grid, row+1, ((1<<col) ^ womenAvailable), N))%mod;
        }
    }
    return dp[row][womenAvailable] = ans;
}

int32_t main() {
    int N; cin>>N;
    vector<vector<int > > grid(N+1, vector<int> (N+1));
    for(int i=1; i<=N; i++) {
        for(int j=1; j<=N; j++) {
            int tmp; cin>>tmp;
            grid[i][j] = tmp;
        }
    }
    memset(dp, -1, sizeof dp);
    cout<<solve(grid, 1, (1<<N)-1 , N)<<endl;
    return 0;
}


Measured memory_bytes: 724516
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s,t;
  cin >> s >> t;
  t=t+t;
  int n=s.size();
  int a = false;
  rep(i,n){
    if(t.substr(i,n)==s)a=true;
  }
  cout <<  (a?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int c[501];
int s[501];
int f[501];

int n;

int nextstart(int tm, int st) {
    for (int i = s[st];;i += f[st]) {
        if (i >= tm) {
            return i;
        }
    }
}

void solve(int st) {
    long ans = 0;
    REPI(i,st,n-1) {
        ans = nextstart(ans, i);
        ans += c[i];
    }
    cout << ans << endl;
}

int main() {
    cin >> n;
    REP(i,n-1) {
        cin >> c[i] >> s[i] >> f[i];
    }
    
    REP(i,n-1) {
        solve(i);
    }
    cout << 0 << endl;
}


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

class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;

    //-1で初期化。最初はすべてバラバラ
    UnionFind(int N){
        parent = vector<int>(N,-1);
    }

    //Aがどのグループに属しているか(Aの根)を調べる
    int root(int A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }

    //自分のいるグループの頂点数を調べる
    int size(int A){
        return -parent[root(A)];
    }

    //AとBをくっつける
    bool unite(int A, int B) {
    //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        //既にくっついているからくっつけない
        if(A == B) return false; 

        //大きいほう(A)に小さいほう(B)をくっつける
        //大小が逆ならひっくり返す
        if(size(A) < size(B)) swap(A,B);

        //Aのサイズを更新する
        parent[A] += parent[B];
        //Bの親をAに変更する
        parent[B] = A;

        return true;
    }

    //AとBが同じグループならtrueを返す
    bool same(int A, int B){
        return root(A)==root(B);
    } 
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int n,m;
    cin>>n>>m;
    UnionFind uni(n);
    for(int i=0;i<m;i++){
        int x,y,z;
        cin>>x>>y>>z;
        x--,y--;
        uni.unite(x,y);
    }
    int ans =0 ;
    for(int i=0;i<n;i++){
        if(i==uni.root(i)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
<?php
  fscanf(STDIN, "%d", $a);
  $search = "%d";
  for($i = 1; $i < $a; $i++) {
   $search .= " %d";
  }
$list = fscanf(STDIN, $search);
$num = 1;
$limit = 0;
foreach($list as $key=>$val) {
  if($key == 0) {
    $limit = $val;
    continue;
  }
 if($limit > $val){
	$num += 1;
   $limit = $val;
 }
}
    
  echo $num;

Measured memory_bytes: 16888
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int A; // 500yen
	int B; // 100yen
	int C; //  50yen 
	int X;

	cin >> A >> B >> C >> X;
	
	int equal_X_count = 0;

	// < ではなく <= であることに注意
	for (int i = 0 ; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				if (500 * i + 100 * j + 50 * k == X) {
					equal_X_count++;
				}
			}
		}
	}
	
	cout << equal_X_count << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
namespace rensyuu1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                int n = int.Parse(line[0]);
                int x = int.Parse(line[1]);
                int o1 = 0;
                if (n == 0 && x == 0)
                {
                    break;
                }
                else if (x / 3 >= n)
                {
                    Console.WriteLine(o1);
                }
                else
                {
                    for (int i1 = n; i1 > x / 3; i1--)
                    {
                        for (int i2 = i1 - 1; i2 > x - i1 - i2 ; i2--)
                        {
                            if (x - i1 - i2 > 0)
                            {
                                o1++;
                            }
                        }
                    }
                    Console.WriteLine(o1);
                }
            }
        }
    }
}


Measured memory_bytes: 15980
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		String S = sc.next();
		if(S.length() <= K){
			System.out.print(S);
		}else{
			System.out.print(S.substring(0,K)+ "...");
		}
	}
}

Measured memory_bytes: 38524
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
// #define iter(a) __typeof(a.begin())
#define FOR(it, a) for (auto it = a.begin(); it != a.end(); ++it)
#define F first
#define S second
#define SZ(a) static_cast<int>((a).size())
#define sz(a) SZ(a)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).begin(), (a).end()
using namespace std;

typedef int64_t ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef uint64_t ull;

#ifdef ONLINE_JUDGE
#define PR(...) (void(0))
#else
#define PR(...) \
  do { cerr << "line : " << __LINE__ << ", " << endl;  \
    pr(#__VA_ARGS__, __VA_ARGS__); } while (0)

template<class T>
void pr(const string& name, T t) {
  cerr << name << ": " << t << endl;
}
template<typename T, typename ... Types>
void pr(const string& names, T t, Types ... rest) {
  auto p = names.find(',');
  cerr << names.substr(0, p) << ": " << t << ", ";
  pr(string(names, p + 1), rest ...);
}
#endif

template<class T, class U> ostream& operator<<(
    ostream& o, const pair<T, U>& v) {
  return o << "(" << v.F << ", " << v.S << ")";
}
template<class T> ostream& operator<<(
    ostream& o, const vector<T>& v) {
  o << "{"; rep(i, SZ(v)) o << (i?", ":"") << v[i]; return o << "}"; }
template<class T, class U> ostream& operator<<(
    ostream& o, const map<T, U>& v) {
  o << "{"; for (const auto& e : v) o << e << ", "; return o << "}"; }
template<class T, class U> ostream& operator<<(
    ostream& o, const unordered_map<T, U>& v) {
  o << "{"; for (const auto& e : v) o << e << ", "; return o << "}"; }
template<class T> ostream& operator<<(ostream& o, const set<T>& v) {
  o << "{"; for (const auto& e : v) o << e << ", "; return o << "}"; }
template<class T> string to_s(const T& v) {
  ostringstream is; is << v; return is.str(); }

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

#define endl '\n'

char outred[1000][1000];
char outblue[1000][1000];

int main(int argc, char *argv[])
{
  int w, h;
  cin >> h >> w;
  vector<string> in(h);
  rep(i, h) cin >> in[i];

  rep(i, h) rep(j, w)
      outred[i][j] = outblue[i][j] = in[i][j];

  rep(i, h) rep(j, w) {
    if(i == h - 1) continue;
    if(i == 0 || j % 2 == 0)
      outred[i][j] = '#';
  }

  rep(i, h) rep(j, w) {
    if(i == 0) continue;
    if(i == h-1 || j % 2 == 1)
      outblue[i][j] = '#';
  }

  rep(i, h) puts(outred[i]);
  puts("");
  rep(i, h) puts(outblue[i]);
}


Measured memory_bytes: 2048
while True:
    h = int(input())
    if h == 0:
        break
    stones = [list() for i in range(h)]
    for i in range(h):
        stones[i] = list(map(int, input().split()))
    ans = 0
    while True:
        # 石を消してスコアを計算
        tmp = 0
        for y in range(h):
            for j in range(3):
                num = stones[y][j]
                count = 0
                for k in range(j, 5):
                    if num == stones[y][k]:
                        count += 1
                    else:
                        break
                if count >= 3:
                    for k in range(j, j+count):
                        stones[y][k] = 0
                    tmp += count * num
                    break
        if tmp == 0:
            break
        ans += tmp
        # 石を落下させる
        for x in range(5):
            settle = h-1
            for y in range(h-1, -1, -1):
                if stones[y][x] != 0:
                    tmp = stones[y][x]
                    stones[y][x] = 0
                    stones[settle][x] = tmp
                    settle -= 1
    print(ans)



Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='C'){
			for(int j=i+1;j<s.size();j++){
				if(s[j]=='F'){
					printf("Yes\n");
					return 0;
				}
			}
		}
	}
	printf("No\n");
	return 0;
}


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

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

    if(N % K == 0){
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}

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

#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF 1e9
#define INFL 1e18
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class ABeginner {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N, R;
	    in >> N >> R;
	    out << R + 100 * max(0, 10 - N) << '\n';
	}
};


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


Measured memory_bytes: 256
using System;
using System.Linq;

namespace EDPC
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            // DP table
            int[,] DP = new int[N, 3];
            int[] a = new int[N];
            int[] b = new int[N];
            int[] c = new int[N];

            // init DP table
            // init value
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < 3; i++)
            {
                DP[0, i] = input[i];
            }

            // Main
            for (int i = 1; i < N; i++)
            {
                input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        if (j != k) DP[i, j] = Math.Max(DP[i, j], DP[i - 1, k] + input[j]);
                    }
                }
            }
            Console.WriteLine(Math.Max(Math.Max(DP[N - 1, 0], DP[N - 1, 1]), DP[N - 1, 2]));
        }
    }
}


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

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		int N = Integer.parseInt(line.substring(0,line.indexOf(" ")));
		int W = Integer.parseInt(line.substring(line.indexOf(" ")+1));
		int[] v = new int[N+1];
		int[] w = new int[N+1];

		for (int i=1; i<N+1; i++) {
			line = br.readLine();
			v[i] = Integer.parseInt(line.substring(0,line.indexOf(" ")));
			w[i] = Integer.parseInt(line.substring(line.indexOf(" ")+1));
		}

		int[][] dp = new int[N+1][W+1];

		for (int i=1; i<N+1; i++) {
			for (int j=1; j<W+1; j++) {
				if (j-w[i] >= 0)
					dp[i][j] = Math.max(dp[i-1][j],dp[i][j-w[i]]+v[i]);
				else
					dp[i][j] = dp[i-1][j];
			}
		}

		System.out.println(dp[N][W]);

		br.close();
	}
}

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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define deb 0

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

	int n;
	cin >> n;
	cout << "ABC" << n << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long a[100002];
long m(long a,long b){
	while(a%b!=0&&b%a!=0){
		if(a>b){
			a=a%b;
		}else{
			b=b%a;
		}
	}
	return min(b,a);
}
int main(){
	long n,k,l;
	cin>>n>>a[0];
	k=a[0];
	for(long i=1;i<=n;i++){
		cin>>a[i];
		k=min(a[i],k);
	}
	if(n==1){
		cout<<abs(a[1]-a[0]);
		return 0;
	}
	n++;
	for(long i=0;i<n;i++){
		a[i]-=k;
	}
	if(a[0]==0){
		k=a[1];
	}else{
		k=a[0];
	}
	for(long i=0;i<n;i++){
//		cout<<"i:"<<i<<endl;
		if(a[i]!=0){
//			cout<<k<<endl<<a[i]<<endl;
			k=m(k,a[i]);
		}
	}
	cout<<k;
	return 0;
}

Measured memory_bytes: 1024
# coding: utf-8
N = int(input())
S = input()
op, cl, pair = [0], [0], [0]
for i in range(N):
    if S[i] == "(":
        op.append(op[-1]+1)
        cl.append(cl[-1])
    else:
        op.append(op[-1])
        cl.append(cl[-1]+1)
for i in range(1, N+1):
    if cl[i-1] < cl[i] and op[i] - pair[-1] > 0:
        pair.append(pair[-1] + 1)
    else:
        pair.append(pair[-1])
o, c, p = op[-1], cl[-1], pair[-1]
if o - p > 0:
    S = S + ")" * (o - p)
    if c - p > 0:
        S = "(" * (c - p) + S
    print(S)
elif c - p > 0:
    S = "(" * (c - p) + S
    print(S)
else:
    print(S)

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

using ll = long long;

constexpr ll inf = 1e18;

ll dp[5001][5001][2];
ll ndp[5001][2];

int main() {
    for(int i = 0; i < 5001; ++i) {
        for(int j = 0; j < 5001; ++j) {
            for(int k = 0; k < 2; ++k) {
                dp[i][j][k] = inf;
            }
        }
    }

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<vector<int>> g(n);
    for(int i = 0; i < n - 1; ++i) {
        int u, v; cin >> u >> v;
        g[u - 1].push_back(v - 1);
        g[v - 1].push_back(u - 1);
    }

    // 1 => including computer
    vector<int> sz(n);
    function<void(int, int)> solve = [&] (int v, int p) {
        sz[v] = 1;
        for(auto to : g[v]) {
            if(to == p) continue;
            solve(to, v);
            sz[v] += sz[to];
        }
        dp[v][0][a[v] < 0] = a[v];
        int cur_sz = 1;
        for(auto to : g[v]) {
            if(to == p) continue;
            for(int i = 0; i <= n; ++i) {
                for(int j = 0; j < 2; ++j) {
                    ndp[i][j] = inf;
                }
            }
            for(int i = 0; i <= cur_sz - 1; ++i) {
                for(int c1 = 0; c1 < 2; ++c1) {
                if(dp[v][i][c1] == inf) continue;
                    for(int j = 0; j <= sz[to] - 1; ++j) {
                        for(int c2 = 0; c2 < 2; ++c2) {
                            if(dp[to][j][c2] == inf) continue;
                            // connect
                            ndp[i + j][max(c1, c2)] = min(ndp[i + j][max(c1, c2)], dp[v][i][c1] + dp[to][j][c2]);
                            // cut
                            if(c2 == 0 || dp[to][j][c2] < 0) {
                                ndp[i + j + 1][c1] = min(ndp[i + j + 1][c1], dp[v][i][c1]);
                            }
                        }
                    }
                }
            }
            memcpy(dp[v], ndp, sizeof(ndp));
            cur_sz += sz[to];
        }
    };
    solve(0, -1);

    int ans = n;
    for(int i = 0; i < n; ++i) {
        if(dp[0][i][0] != inf || dp[0][i][1] < 0) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 392192
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, u641) => {
        read_value!($iter, u64) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn ds(a: u64, b: u64, k:u64) -> bool {
    if a > b {
        return a - b > k;
    } else {
        return b - a > k;
    }
}

fn main() {
    input! {
        a: u64,
        b: u64,
        c: u64,
        d: u64,
        e: u64,
        k: u64,
    }

    if ds(a,b,k) {
        println!(":(");
        return;
    } else if ds(b,c,k) {
        println!(":(");
        return;
    } else if ds(c,d,k) {
        println!(":(");
        return;
    } else if ds(d,e,k) {
        println!(":(");
        return;
    } else if ds(e,a,k) {
        println!(":(");
        return;
    } else {
        println!("Yay!");
        return;
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  char X,Y;
  cin>>X>>Y;
  if(X==Y){cout<<'='<<endl;}
  else if(X>Y){cout<<'>'<<endl;}
  else{cout<<'<'<<endl;}
  return 0;  
}

Measured memory_bytes: 3644
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var HWAB = Sarray();
            var H = HWAB[0];
            var W = HWAB[1];
            var A = HWAB[2];
            var B = HWAB[3];
            if (A == 0) A = W;
            if (B == 0) B = H;
            var ban = Enumerable.Range(0, (int)H).Select(_ => new long[W]).ToArray();
            for (var h = 0; h < B; ++h)
                for (var w = 0; w < A; ++w)
                    ban[h][w] = 1;
            for (var h = B; h < H; ++h)
                for (var w = A; w < W; ++w)
                    ban[h][w] = 1;

            for (var h = 0; h < H; ++h)
                WriteLine(string.Join("", ban[h]));
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 26448
#include<stdio.h>
int main(){
  int H,W,h,w;
  scanf("%d%d%d%d",&H,&W,&h,&w);
  if(H%h||W%w){
    puts("Yes");
    for(int i=1;i<=H;++i,puts("")) for(int j=1;j<=W;++j)
      printf("%d ", (i%h||j%w)?1000:-1000*(h*w-1)-1);
  }else puts("No");
  return 0;
}

Measured memory_bytes: 1536
k, n = map(int, input().split())
a = list(map(int, input().split()))
mx = 0
ans = 0
for i in range(n-1):
    ans += a[i+1] - a[i]
    mx = max(mx, a[i+1] - a[i])
ans += (k-a[-1]) + a[0]
mx = max(mx, (k-a[-1]) + a[0])
print(ans - mx)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair <int,int>
#define vpii vector< pair<int,int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int a, b, i;
	cin >> a;
	cin >> b;
	map <int, int> mp;
	mp[a]++, mp[b]++;
	foe(i, 1, 3){
		if(mp[i] == 0){
			cout << i;
			return 0;
		}
	}
}

Measured memory_bytes: 256