akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    string s;
    cin >> s;
    int k = s.length();
    int cnt = 0;
    REP(i,k) if (s[i] == 'o') cnt++;
    if (k <= 7) {
        cout << "YES" << endl;
    }
    else if (k-cnt <= 7) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>


using namespace std;

int main() {
  int n,m,p,A[100001][2],wa=0,ac=0;
  string s;
  cin >> n>>m;
  for(int i=0;i<n;i++){
    A[i][0]=0;
    A[i][1]=0;
  }
  for(int i=0;i<m;i++){
    cin >>p>>s;
    if(s=="AC"){
      A[p-1][1]=1;
    }else{
      if(A[p-1][1]==1){
        continue;
      }else{
        A[p-1][0]++;
      }
    }
  }
  for(int i=0;i<n;i++){
    ac+=A[i][1];
    if(A[i][1]==1)wa+=A[i][0];
  }
  cout<<ac<<" "<<wa<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void)
{
  long long int n, ans = 0;
  cin >> n;
  
  vector<long long int> d(n);
  for(int i = 0; i < n; i++)
  {
    cin >> d[i];
  }
  n /= 2;
  sort(d.begin(),d.end());
  
  ans = d[n] - d[n-1];
  cout << ans;
  return 0;
}

Measured memory_bytes: 1024
/****************************************************
/@Author: Kirito
/@TIME:   2020-05-04
/@FILENAME: trickoftreat.cpp
/@REMARK:    
/****************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;

const int maxn=111;
int n,k,book[maxn];

int main()
{
    FAST;CSE(book,0);
    cin>>n>>k;
    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        for(int j=0;j<d;j++){
            int x;
            cin>>x;
            book[x]=1;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!book[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int main() {

	string S;
	long long K;
	int l = 0;
	char c = 0;
	cin >> S >> K;
	int i = 0;
	for (int i = 0; i != S.length(); ++i) {
		c = S[i];
		if (c == '1') {
			l++;
		}
		else {
			break;
		}
	}

	if (l >= K)cout << 1 << endl;
	else cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
n=int(input())
w=[]
ans='Yes'
for i in range(n):
    w.append(list(input()))
    if i==0:
        continue
    if w[i][0]!=w[i-1][len(w[i-1])-1]:
            ans='No'
            break
    for j in range(i):
        if w[i]==w[j]:
            ans='No'
            break
print(ans)
    

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

int n, m, t, a[MXN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

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

bool is_palindrome(int n) {
  string s = to_string(n);
  for (int i = 0, j = s.length() - 1; i < s.length() / 2; ++i) {
    if (j > s.length() / 2 and s[i] != s[j]) return false;
    --j;
  }
  return true;
}

int main() {
  fast();
  cin >> n >> m;
  int ans = 0;
  for (int i = n; i <= m; ++i)
    if (is_palindrome(i)) ++ans;
  cout << ans;
  return 0;
}



Measured memory_bytes: 3660
using System;
	public class Class1
	{
		public static void Main()
		{  
			int n=int.Parse(Console.ReadLine());
				
			int x=0;
			int y=0;
				for(int i=1;i<=n;i++)
				{    x =i;
					while(x>10)
					{
						x/=10;
						if(x%10==3)
						{
							y=99;
							break;
						}
							
					}
					if(i%3==0|i%10==3|y==99)
					 {  
						y=0;
						Console.Write(" "+i);
					}
				}
				Console.WriteLine();
				
		}
	}
			    
			    		

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

int main() {
 int N;
 cin >> N;
 vector<int> A(N);
 for (int i=0; i<N; i++){
  cin >> A[i];
 }
 sort(A.begin(), A.end());
 reverse(A.begin(), A.end());

 int ALICE=0;
 int BOB=0;
 for (int k=0; k<N; k+=2){
  ALICE+=A[k];
  BOB+=A[k+1];
 }
 cout << ALICE-BOB << endl;
}


Measured memory_bytes: 256
h,w = map(int, raw_input().split())
mat = [[0 for i in xrange(w)] for j in xrange(h)]
a,b = map(int, raw_input().split())
for i in xrange(a):
	for j in xrange(w):
		mat[i][j] = 1
for i in xrange(b):
	for j in xrange(h):
		mat[j][i] = 1
ans = 0
for i in xrange(h):
	for j in xrange(w):
		ans += mat[i][j]
print h*w-ans

Measured memory_bytes: 27884
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

long long int gcd(long long int a, long long int b) {
    if (a < b)swap(a, b);
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;cin >> N>>K;
    VL A(N);
    REP(i,N) {
        cin >> A[i];
    }
    int Amin = *min_element(A.begin(),A.end());
    int Amax = *max_element(A.begin(),A.end());

    if(Amin > K || Amax < K){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    if(N == 1){
        if(A[0] == K){
            cout << "POSSIBLE" << endl;
        }
        else{
            cout << "IMPOSSIBLE" << endl;
        }
        return 0;
    }


    sort(A.begin(),A.end());
    int base = A[0];
    int mingcd = INF;
    FOR(i,1,N){
        int tmp = gcd(base,A[i]);
        if(tmp < mingcd) mingcd = tmp;
    }

    if(K % mingcd == 0){
        cout << "POSSIBLE" << endl;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 1024
package main
import (
  "fmt"
)

func main() {
  var N, Y int
  fmt.Scan(&N, &Y)
  for i := 0; i <= N; i++ {
    for j := 0; j <= N - i; j++ {
      if Y == 10000 * i + 5000 * j + 1000 * (N - i - j) {
        fmt.Println(i, j, (N - i - j))
        return
      }
    }
  }
  fmt.Println("-1 -1 -1")
}


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

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))


using namespace std;


typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 

const int inf = 1000000000;
int N,M,R;
int dp[10][1000], E[500][500];
vi city;

int minPath(int k,int state){
	if(!state) return 0;
	assert(1&(state>>k));
	if(dp[k][state]>=0) return dp[k][state];
	dp[k][state] = inf;
	bool ok = true;
	for(int j=0;j<R;++j) if(1&(state>>j)){
		if(j==k) continue;
		dp[k][state] = min(dp[k][state], E[city[j]][city[k]] + minPath(j, state-(1<<k)));
		ok = false;
	}
	if(ok) dp[k][state] = 0;
	return dp[k][state];
}

int main(){
	cin>>N>>M>>R;
	city.resize(R);
	for(int i=0;i<R;++i) {
		cin>>city[i];
		city[i]--;
	}
	for(int i=0;i<N;++i){
		E[i][i] = 0;
		for(int j=i+1;j<N;++j) E[i][j] = E[j][i] = inf;
	}
	for(int i=0;i<M;++i){
		int A,B,C;
		cin>>A>>B>>C;
		E[A-1][B-1] = E[B-1][A-1] = C;
	}
	for(int k=0;k<N;++k) for(int i=0;i<N;++i) for(int j=0;j<N;++j) E[i][j] = min(E[i][j], E[i][k]+E[k][j]);
	int ans = inf, final = (1<<R)-1;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<R;++i){
		ans = min(ans,minPath(i,final));
	}
	cout<<ans<<endl;
	return 0; 
}


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

int main()
{
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    char a=(char)toupper(s1[0]),b=(char)toupper(s2[0]),c=(char)toupper(s3[0]);
    cout<<a<<b<<c;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;

int main(){
	int r, d, x;
	cin >> r >> d >> x;
	for(int i = 0;i < 10;i++){
		x = r*x-d;
		cout << x << endl;
	}
}

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

int main(void){
    
    // 時間の定義とか奴
    int N;
    int M;
    int h, m;
    int time[200] = {1500};
    
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> h >> m;
        time[i] = (h*60) + m;
    }   


    cin >> M;
    for(int j = N; j < N+M; j++){
        cin >> h >> m;
        time[j] = (h*60) + m;
    }  
 
    sort(time, time+N+M);
 
    for(int i = 0; i < N+M; i++){
        if(time[i] == time[i+1]) continue;
        cout << time[i] / 60 << ":" << ( (time[i] % 60 < 10) ? "0" : "" ) << time[i] % 60  << ( (i != N+M-1) ? " " : "\n" );
        
    }
    
    
}



Measured memory_bytes: 3164
N = int(input())
A = list(map(int, input().split()))

flag = 0

for i in A:
  if i%2==0 and (i%3 != 0 and i%5 != 0):
    flag = 1
    
if flag == 0:
  print("APPROVED")
  
else:
  print("DENIED")

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,l=-1000000,r=1000000;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=max(l,m-n+1);i<=min(r,m+n-1);i++)printf("%d ",i);
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
const int size=4000;
bool visited[size][size];
int distances[size][size];
vector<int> graph[size];
int amount, diameter;
void fillingGraph()
{
	cin>>amount>>diameter;
	int vertex0, vertex1;
	for(int i=1; i<=amount; ++i)
	{
		cin>>vertex0>>vertex1;
		graph[vertex0].push_back(vertex1);
		graph[vertex1].push_back(vertex0);
	}
	return;
}
void dfs(int root, int first, int distance)
{
	stack<int> stack;
	stack.push(first);
	distances[root][first]=distance;
	while(!stack.empty())
	{
		first=stack.top();
		stack.pop();
		visited[root][first]=true;
		for(int second : graph[first])
		{
			if(!visited[root][second])
			{
				stack.push(second);
				distances[root][second]=distances[root][first]+1;
			}
		}
	}
	return;
}
void usingDFS()
{
	for(int point=1; point<=amount; ++point)
	{
		dfs(point, point, 0);
	}
	if(diameter%2==0)
	{
		int counterEven, minimumEven=4000;
		for(int i=1; i<=amount; ++i)
		{
			counterEven=0;
			for(int j=1; j<=amount; ++j)
			{
				if(distances[i][j]>diameter/2)
				{
					++counterEven;
				}
			}
			minimumEven=min(minimumEven, counterEven);
		}
	cout<<minimumEven<<endl;
	}
	if(diameter%2!=0)
	{
		int counterOdd, minimumOdd=4000, temporary;
		for(int i=1; i<=amount; ++i)
		{
			for(int j=1; j<=amount; ++j)
			{
				if(distances[i][j]==1)
				{
					counterOdd=0;
					for(int k=1; k<=amount; ++k)
					{
						temporary=min(distances[k][i], distances[k][j]);
						if(temporary>diameter/2)
						{
							++counterOdd;
						}
					}
					minimumOdd=min(minimumOdd, counterOdd);
				}
			}
		}
	cout<<minimumOdd<<endl;
	}
	return;
}
int main()
{
	fillingGraph();
	usingDFS();
	return 0;
}

Measured memory_bytes: 43008
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, n) for(long long (i) = (a); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define GET(v) cin >> (v)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int main()
{
    int a, b, c;
    GET3(a, b, c);
    
    if(abs(b - c) % 2 == 0) {
        SHOW("Alice");
    }
    else {
        SHOW("Borys");
    }
    
    return 0;
}



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

int main()
{
	int n,k=0;
	cin>>n;
	if(n%2==0||n%5==0)
	{
		cout<<"-1";
		return 0;
	}
	
	for(int i=1;i;i++)
	{
		k=(k*10+7)%n;
		if(k==0)
		{
			cout<<i;
			return 0;
		}
	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;

template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)

int main() {
    string a, b, c;
    while (cin >> a >> b >> c) {
        bool res = a.back() == b.front() && b.back() == c.front();
        puts(res ? "YES" : "NO");
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str[];
        str = new String[3];
        int num1, num2, Ans;
        Ans =0;
        for (int i=1;;i++)
        {
        str[0] = in.next();
        str[1] = in.next();
        str[2] = in.next();
        num1 = Integer.parseInt(str[0]);
        num2 = Integer.parseInt(str[2]);
        if (str[1].equals("?")){break;}
        else{
        if (str[1].equals("+")){Ans = num1+num2;}
        if (str[1].equals("-")){Ans = num1-num2;}
        if (str[1].equals("*")){Ans = num1*num2;}
        if (str[1].equals("/")){Ans = num1/num2;}
        System.out.println(Ans);}
        }
    }
    
}

Measured memory_bytes: 26144
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  int ab,bc;
  cin>>ab>>bc;
  cout<<ab*bc/2.0<<endl;
}

Measured memory_bytes: 256
/*
*
*/
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#define CLR(ARR,NUM) memset(ARR,NUM,sizeof(ARR))
#define GETNUM(NUM) scanf("%d",&NUM)
#define faster_io() ios_base::sync_with_stdio(false)
using namespace std;
const int MAXN = 1010;
char map[MAXN][MAXN];
bool vis[10][MAXN][MAXN];
struct node{
	int x;
	int y;
	int deep;
	int n;
};
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};

int main()
{
	CLR(vis,false);
	CLR(map,'X');
	int h,w,n;
	cin >> h >> w >> n;
	getchar();
	int sx,sy;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			map[i][j]=getchar();
			if(map[i][j]=='S'){
				sx=i;
				sy=j;
			}
		}
		getchar();
	}
	node t;
	t.x=sx;
	t.y=sy;
	t.deep=0;
	t.n=0;
	queue<node>q;
	vis[0][sx][sy]=true;
	q.push(t);
	int ans = -1;
	while(!q.empty()){
		node cur=q.front();
		if(cur.n==n){
			ans=cur.deep;
			break;
		}
		q.pop();
		for(int i=0;i<4;i++){
			int tx=cur.x+dx[i];
			int ty=cur.y+dy[i];
			if(map[tx][ty]!='X'&&!vis[cur.n][tx][ty]){
				node t = cur;
				t.x=tx;
				t.y=ty;
				t.deep++;
				if(map[tx][ty]=='1'+t.n){
					t.n++;
				}
				vis[t.n][tx][ty]=true;
				q.push(t);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int H, W;
	while (true){
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				if( (i%(H-1))*(j%(W-1)) == 0 )cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long
using namespace std;

ll Ha, Hb, Hc, Hx, Hy, Hz, Hmax, Hmin;
ll ans;
ll a,b;

ll temp;

int main() {
	cin >> a >> b;
	Ha = a*b;

	if (a < b){
		temp = a;
		a = b;
		b = temp;
	}

	Hb = a%b;
	while (Hb != 0){
		a = b;
		b = Hb;
		Hb = a%b;
	}
	ans = Ha / b;
	cout << ans << endl;
	return 0;
}



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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int n;
ll a[112345];
string op[112345];
ll dp[112345][3];

int main() {
	cin >> n;
	cin >> a[0]; op[0] = "+";
	REP(i, n - 1) cin >> op[i + 1] >> a[i + 1];
	
	fill(dp[0], dp[n + 1], -INF);
	dp[0][0] = 0;
	
	REP(i, n) {
		REP(j, 3) {
			if (dp[i][j] == -INF) continue;
			
			REP(k, 3) {
				int nextj = j - k;
				if (nextj < 0) continue;
				
				if (op[i] == "-") {
					if (nextj == 2) nextj = 1;
					else nextj++;
				}
				
				chmax(dp[i + 1][nextj], dp[i][j] + a[i] * (nextj & 1 ? -1 : 1));
			}
		}
	}
	
	
	ll ans = -INF;
	REP(i, 3) chmax(ans, dp[n][i]);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 9216
import sys
input=sys.stdin.readline

def main():
    _ = int(input())
    S = input().strip()
    ans = ""
    l = r = 0
    for c in S:
        if c == "(":
            r += 1
        elif c == ")":
            if r > 0:
                r -= 1
            else:
                l += 1
    ans = "("*l + S + ")"*r
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))

for i in range(1, N):
  a = A[i - 1]
  b = A[i]
  while a != b:
    if a < b:
      b -= (b // a) * a
      if b == 0:
        b = a
    else:
      a -= (a // b) * b
      if a == 0:
        a = b
  A[i - 1] = a
  A[i] = b
  
print(A[-1])

Measured memory_bytes: 14224
H,W,K=map(int,input().split())

M=[[0 for i in range(W)] for f in range(H)]
A=[[0 for i in range(W)] for f in range(H)]

for i in range(H):
    M[i]=list(input())

f=1
s=1
for i in range(W):
    c=0
    for j in range(H):
        if(M[j][i]=="#"):
            c+=1
    if(c==0):
        f+=1
    else:
        t=0
        for j in range(H):
            if(M[j][i]=="#"):
                t+=1
                if(t>1):
                    s+=1     
            for k in range(f):
                A[j][i-k]=s
        f=1
        s+=1
for i in range(W-1,-1,-1):
    if(A[0][i]!=0):
        for j in range(i,W):
            for k in range(H):
                A[k][j]=A[k][i]
        break

for i in range(H):
    for j in range(W):
        print(A[i][j],end=" ")
    print()


Measured memory_bytes: 55384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n; cin >> n;
	P a[n];
	zep(i, 0, n){
		ll buf; cin >> buf;
		a[i] = P(buf, i);
	}
	sort(a, a+n);
	
	ll dp[n+1][n+1];
	dp[0][0] = 0;
	rrep(i, n-1, 0){
		ll ai = a[i].first, pos = a[i].second;
		ll len = n-i;
		
		rep(j, 0, len){
			dp[j][len-j] = 0;
			if(j > 0){dp[j][len-j] = max(dp[j][len-j], dp[j-1][len-j]+ai*abs(j-1-pos));}
			if(len-j > 0){dp[j][len-j] = max(dp[j][len-j], dp[j][len-j-1]+ai*abs(n-(len-j)-pos));}
			//cout << j << " " << len-j << " " << dp[j][len-j] << endl;
		}
	}
	
	ll ans = 0;
	rep(i, 0, n){
		ans = max(ans, dp[i][n-i]);
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 26272
#include <iostream>
#include <map>
#include <vector>
#include <string>

//#define _USE_MATH_DEFINES
//#include<math.h>
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
	int R;
	cin >> R;
	
	cout << 2 * PI * R << endl;
	return 0;
}

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

using namespace std;

int N;
vector<int> ip;
bool fs = false;

bool test(int a) {
  int id = 0;
  int t = 0;
  while (id < N) {
    int j = id;
    while (ip[j] - ip[id] < a and j < N) {
      j ++;
    }
    t += (j - id - 1);
    id = j;
  }
  int n = N - 2;
  int want = fs ? (n - n / 2) : n / 2;
  if (t <= want) return true;
  else return false;
}

bool test2(int a) {
  int z = N/2, q = N/2;
  int r = 0;
  for (int i=0; i<z; i++) {
    int t = ip[i+q] - ip[i];
    if (t < a) {
      if (r) return false;
      r = 1;
      q ++;
      t = ip[i+q] - ip[i];
      if (t < a) return false;
    }
  }
  return true;
}

int main() {
  cin >> N;
  string s;
  cin >> s;
  if (s == "Alice") fs = true;
  for (int i=0; i<N; i++) {
    int a; cin >> a;
    ip.push_back(a);
  }
  sort(ip.begin(), ip.end());
  
  if ((N&1) and !fs or !(N&1) and fs) {
    int l = 0, r = ip.back();
    while (l < r) {
      int md = (l+r+1) / 2;
      if (test(md)) {
        l = md;
      } else {
        r = md - 1;
      }
    }
    cout << l << endl;
  } else if (!(N&1)) {
    int ans = 1029384756;
    int z = N/2;
    for (int i=0; i<z; i++) {
      ans = min(ans, ip[z+i] - ip[i]);
    }
    cout << ans << endl;
  } else {
    int l = 0, r = ip.back();
    while (l < r) {
      int md = (l+r+1) / 2;
      if (test2(md)) {
        l = md;
      } else {
        r = md - 1;
      }
    }
    cout << l << endl;
  }
}

Measured memory_bytes: 3576
import math

# f(x) = 0からxまでのxor
def f(x):
    div = (x // 2) % 2
    if x % 2 == 0:
        return div ^ x
    else:
        return div ^ 1

A, B = map(int, input().split())
print(f(A - 1) ^ f(B))


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;


string s;

pair<int,int> judge(){
    char c1=s[0],c2=s[1];
    if(c1==c2)return make_pair(1,2);
    for(int i=2;i<s.size();i++){
        if(c1==s[i])return make_pair(i-1,i+1);
        if(c2==s[i])return make_pair(i,i+1);
        c1=c2;
        c2=s[i];
    }
    return make_pair(-1,-1);
}

int main(){
    
    cin>>s;
    pair<int,int> t=judge();
    cout<<t.first<<" "<<t.second<<endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 1e5+5;
ll n, arr[nax], pref[nax], sums=0;

int main(){
	IOS
	cin >> n;
	for(int i=1;i<=n;++i){
		cin >> arr[i];
	}
	pref[0]=0, pref[n+1]=0;
	for(int i=1;i<=n+1;++i){
		pref[i]=abs(arr[i]-arr[i-1]);
		sums+=pref[i];
	}
	for(int i=1;i<=n;++i){
		cout << sums-abs(arr[i]-arr[i-1])-abs(arr[i]-arr[i+1])+abs(arr[i-1]-arr[i+1]) << '\n';
	}
}


Measured memory_bytes: 5192
#include <iostream>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

int main()
{
    int N, M;
    vector<int> ans, check;

    cin >> N >> M;
    ans.resize(N, 0);
    check.resize(N, 0);
    if(N != 1){
        ans[0] = 1;
    }
    for (int i = 0; i < M; i++){
        int s, c;
        cin >> s >> c;
        s--;
        if((N != 1) && (s == 0) && (c == 0)){
            cout << -1 << endl;
            return 0;
        }
        if((check[s] != 0) && (ans[s] != c)){
            cout << -1 << endl;
            return 0;
        }
        check[s]++;
        ans[s] = c;
    }

    string str = "";
    for (int i = 0; i < ans.size(); i++){
        str += (char)(ans[i] + '0');
    }
    cout << atoi(str.c_str()) << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

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

	for (int e = 0; e < N;e++){
		scanf("%d", &A[e]);
	}
  
		 qsort(A, N, sizeof(int), compare_int);

		 printf("%d",A[N-1]-A[0]);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

ll gcd(ll a,ll b){
	if(a<b){
		swap(a,b);
	}

	while(ll r=(a%b)){
		a = b;
		b = r;
	}
	return b;

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

	int A=in(),B=in();
	
	out(gcd(A,B));
	return 0;
}



Measured memory_bytes: 3192
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

abc='abcdefghijklmnopqrstuvwxyz'

n=int(input())

ans=''
while n!=0:
  t_ans=n%26
  ans+=str(abc[t_ans-1])

  if abc[t_ans-1]=='z':
    n-=1

  n//=26

print(ans[::-1])

Measured memory_bytes: 9160
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
int a[1000001];
signed main() {
	int n;
	cin >> n;
	int ans = 0;
	if (n == 1) { cout << 4 << endl; return 0; }
	else if (n == 2) { cout << 4 << endl; return 0; }
	else if (n == 4) { cout << 4 << endl; return 0; }
	else {
		while (n != 4) {
			if (n % 2 == 0)n /= 2;
			else n = n * 3 + 1;
			ans++;
		}
		cout << ans + 4 << endl;
	}
}

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

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

  S.pop_back();

  while (S.size()) {
    if (S.substr(0, S.size() / 2) == S.substr(S.size() / 2)) {
      cout << S.size() << "\n";
      return 0;
    }
    S.pop_back();
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007

void solve(mat& tree,ll now,vec& plist,vec& ans,ll plus,vec& ch){
  ll i,K=tree[now].size();
  ch[now]++;
  ans[now]=plus+plist[now];
  //<<now<<" "<<plist[now]<<endl;
  rep(i,K){
    if(ch[tree[now][i]])continue;
    solve(tree,tree[now][i],plist,ans,ans[now],ch);
  }
}

int main(){
  ll i,a,b,N,Q;
  cin>>N>>Q;
  mat tree(N);
  vec ans(N,0),plist(N,0),ch(N,0);
  rep1(i,N){
    cin>>a>>b;
    tree[a-1].push_back(b-1);
    tree[b-1].push_back(a-1);
  }
  rep(i,Q){
    cin>>a>>b;
    plist[a-1]+=b;
  }
  solve(tree,0,plist,ans,0,ch);

  rep(i,N)cout<<ans[i]<<" ";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 33664
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) r.begin(),r.end()

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007;

vi v(10010);

void init(int n){
	rep(i,n)v[i]=i;
}

int root(int a){
	if(v[a]==a)return a;
	return (v[a]=root(v[a]));
}

void unite(int a,int b){
	v[root(a)]=root(b);
}

bool same(int a,int b){
	return root(a)==root(b);
}

int main(){
	int n,q,c,x,y;
	cin>>n>>q;
	init(n);
	for(int i=0; i<q; i++){
		cin>>c>>x>>y;
		if(c==0)unite(x,y);
		else cout<<(same(x,y)?1:0)<<endl;
	}
}

Measured memory_bytes: 1348
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <vector>
#define ll long long
#define INF 1000000000
using namespace std;

int d[201][201];//i,j間の最短距離
int E, V;//辺,頂点

void init(){
    REP(i, V){
        REP(j, V){
            if(i == j) d[i][j] = 0;
            else d[i][j] = INF;
        }
    }
}

void make(){
    REP(i, E){
        int u, v, c;
        cin >> u >> v >> c;
        u--; v--;
        d[u][v] = c;
        d[v][u] = c;
    }
}

void wd(){
    REP(k, V){
        REP(i, V){
            REP(j, V){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main(){

    int R;
    cin >> V >> E >> R;
    vector<int> town;

    init();

    REP(i,R){
        int in;
        cin >> in;
        in--;
        town.push_back(in);
    }


    make();
    wd();
    
    sort(town.begin(), town.end());

    int min_distance = 1000000001;    
    do {
        int cost = 0;
        REP(i, R-1){
             cost += d[town[i]][town[i+1]];
        }

        min_distance = min(cost, min_distance);

    } while(next_permutation(town.begin(), town.end()));


    cout << min_distance << endl;

}

Measured memory_bytes: 512
<?php
    $input = trim(fgets(STDIN));
    $input = explode(" ", $input);
    
    $A = $input[0];
    $B = $input[1];
    $C = $input[2];
    $cnt = 0;
    if($C <= ($A+$B)) $cnt = $B + $C;
    else $cnt = ($A+$B+1) +$B;
    
    echo $cnt;
?>



Measured memory_bytes: 3828
import heapq

N = int(input())
red, blue, both = [], [], []
for _ in range(N):
    x, y = map(int, input().split())
    red.append((x, y))
    both.append((x, y, True))
for _ in range(N):
    x, y = map(int, input().split())
    blue.append((x, y))
    both.append((x, y, False))

# both.sort(key=lambda xyz: xyz[1])
both.sort(key=lambda xyz: xyz[0])

# According to the heapq documentation, the way to customize the heap order is
# to have each element on the heap to be a tuple, with the first tuple element
# being one that accepts normal Python comparisons.
red_heap = []
ans = 0
for xyz in both:
    y = xyz[1]
    if xyz[2]:
        heapq.heappush(red_heap, (-y, xyz))
    else:
        popped = []
        while red_heap:
            r = heapq.heappop(red_heap)
            if r[1][1] < y:
                ans += 1
                break
            popped.append(r)
        for r in popped:
            heapq.heappush(red_heap, r)

print(ans)


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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}



int main()
{
	FASTIO;
	ll n;
	 cin>>n;
	 vector<ll>vect(n);
	 f(i,0,n)
        cin>>vect[i];
        ll ans=0;
        for(int i=1;i<n-1;i++)
        {
            vector<int>temp;
            temp.push_back(vect[i-1]);
             temp.push_back(vect[i]);
              temp.push_back(vect[i+1]);
              sort(temp.begin(),temp.end());
              if(temp[1]==vect[i])
                ans++;
        }
        cout<<ans<<"\n";
	return 0;
}













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

public static class Program
{
    public static void Main()
    {
        var line = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = line[0];
        var k = line[1];
        var aArray = ReadLine().Split(' ').Select(int.Parse).ToArray();
        for(int i = 0; i < n - k; ++i)
        {
            if (aArray[i] < aArray[k + i])
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 46252
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

ll bitCount(ll n){
    ll ans = 0;
    while(n > 0){
        if(n & 1) ans++;
        n = n >> 1;
    }
    return ans;
}

const ll mod = 1e9 + 7;

int main(){
    ll N; cin >> N;
    vvl a(N, vl(N, 0)); REP(i, N) REP(j, N) cin >> a[i][j];
    vl dp(1<<N, 0); dp[0] = 1;
    
    REP(i, 1<<N){
        ll k = bitCount(i);
        REP(j, N){
            if(i & (1<<j)) continue;
            if(!a[k][j]) continue;
            dp[i|(1<<j)] += dp[i];
            dp[i|(1<<j)] %= mod;
        }
    }
    cout << dp[(1<<N)-1] % mod << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

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

   unsigned long long int K;
   cin>>K;
   int N=50;
   vector<unsigned long long int>a(N);
   //cout<<size<<endl;

   for(int i=0;i<N;i++)a[i]=i;

   unsigned long long num = K%50;
   for(int i=0;i<num;i++){
      a[i]+=N;
      for(int j=0;j<N;j++){
         if(i==j)continue;
         a[j]--;
      }
   }
   K -= num;

   cout<<50<<endl;
   for(int i=0;i<50;i++)cout<<a[i]+K/50<<" ";
   cout<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;


int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double x1, x2, y1, y2;
    double t1 = 2*M_PI*(h*60.0+m)/720.0; 
    double t2 = 2*M_PI*m/60.0;
    //debug(t1);
    //debug(t2);
    
    x1 = a*cos(t1);
    y1 = a*sin(t1);
    x2 = b*cos(t2);
    y2 = b*sin(t2);
    double ans = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    printf("%.10f\n", ans);
    
    return 0;
}


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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	auto a = load<int>();
	auto b = load<int>();
	auto k = (a+b)/2;
	if (abs(a - k) == abs(b - k))
		cout << k << '\n';
	else cout << "IMPOSSIBLE\n";
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
// cin.eof() 入力個数の問題

int main() {
    int k,s;
    cin>>k>>s;
    int ans=0;
    rep(i,k+1){
        rep(j,k+1){
            int x=s-i-j;
            if(0<=x&&x<=k) ans++;
    
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

void print(int n,int a[]){

  int i;
  for(i=0;i<n;i++){

    if(i) printf(" ");
    printf("%d",a[i]);

  }

  puts("");

}

int main(){

  int n,i;
  int a[1000];

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&a[i]);

  for(i=0;i<n;i++){

    int v=a[i];
    int j=i-1;

    for(;j>=0 && a[j]>v;j--) a[j+1]=a[j];

    a[j+1]=v;

    print(n,a);

  }

  return 0;

}



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

using namespace std;

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n%2 == 1){
        puts("No");
        return 0;
    }else{
        string a = s.substr(0, n / 2);
        string b = s.substr(n/2, n/2);
        if(a==b){
            puts("Yes");
        }else{
            puts("No");
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h,w;
  int i,j;
  scanf("%d %d",&h,&w);
  while(h!=0||w!=0){
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if((i+j)%2==0){
	  printf("#");
	}else{
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d %d",&h,&w);
  }
  return(0);
}

Measured memory_bytes: 2680
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,m,k;
  cin >> n >> m >> k;
  vector<ll> a(n + 1), b(m + 1);
  rep(i, n){
    cin >> a[i + 1];
    a[i + 1] += a[i];
  }
  rep(i, m){
    cin >> b[i + 1];
    b[i + 1] += b[i];
  }
  int ans = 0;
  rep(i, n + 1){
    if(a[i] > k) break;
    int res = upper_bound(all(b), k - a[i]) - b.begin() - 1;
    ans = max(ans, i + res);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6424
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	int k;
	string s;
	cin>>k>>s;
	if(sz(s)<=k)cout<<s<<"\n";
	else{
		cout<<s.substr(0,k)<<"...\n";
	}
	return 0;
}

//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int n,k,d[105],zhuang[105],num=0,l;
int main(){
	memset(zhuang,0,sizeof(zhuang));
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		cin>>l;
		for(int i=1;i<=l;i++){
			cin>>d[i];
			zhuang[d[i]]=1;
		}
	}
	for(int i=1;i<=n;i++){
		if(zhuang[i]==0) num++;
	}
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    int n;
    cin>>n;
    vector<long long> arr(n,0);
    for(long long i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    vector<vector<long long>> dp(n,vector<long long>(n,0));
    for(int l=n-1;l>=0;l--)
    {
        for(int r=l;r<n;r++)
        {
            if(r==l)
             dp[l][r]=arr[l];
            else
             dp[l][r]=max(arr[l]-dp[l+1][r],arr[r]-dp[l][r-1]);
        }
    }
    cout<<dp[0][n-1];
return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
int main(){
    // Your code here!
    int k;
    string s;
  	string ten = "...";
    cin >> k >> s;
    int n = min((int)s.size(),k);
    for(int i = 0;i < n;i++) cout << s[i];
    if((int)s.size() > k) cout << ten;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3624