akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N, M, K; cin >> N >> M >> K;
	vector<ll> a(N + 1), b(M + 1), sa(N + 1), sb(M + 1);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		sa[i + 1] = sa[i] + a[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> b[i];
		sb[i + 1] = sb[i] + b[i];
	}

	ll ans = 0;
	for (int i = 0; i <= N; i++) {
		if (sa[i] > K) continue;
		auto it = upper_bound(sb.begin(), sb.end(), K - sa[i]);
		ll temp;
		//cout << "bi" << endl;
		if (it == sb.end()) {
			if (sa[i] + sb[M] > K) temp = i + M - 1;
			else temp = i + M;
			//cout << sa[i] << " " << sb[M] << endl;
		}
		else {
			//cout << "n";
			temp = i + (ll)(it - sb.begin());
			if (sa[i] + *it > K) temp--;
			//cout << sa[i] << " " << *it << endl;
		}
		ans = max(ans, temp);
		//cout << ans << endl;
	}

	cout << ans << endl;
}

Measured memory_bytes: 9596
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(int i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(int i=pos[x];~i;i=e[i].next)
const int N=7;
const int INF=1e9+7;
#define db long double

int main(){
	db n,m,d;
	scanf("%LF%LF%LF",&n,&m,&d);
	if(d==0)printf("%.10LF\n",(m-1)/n);
	else printf("%.10LF\n",(m-1)*(n-d)*2/n/n);
	return 0;
}


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

int main() {
  int n;
  string type = "Three"; 
  cin >> n;
  for(int i = 0; i < n; i++){
    string color;
    cin >> color;
    if(color == "Y")
      type = "Four";
  }
  cout << type << endl;
}


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

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

    long long val1 = N % K;
    long long val2 = (N / K + 1) * K - N;
    cout << min(val1, val2) << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};



int main(){
  double a, b, h, m; cin >> a >> b >> h >> m;
  double kaku = max(h * 30 + m * 0.5, m * 6) - min(h * 30 + m * 0.5, m * 6);
  // cout << kaku << endl;
  double ans = sqrt(a * a + b * b - 2 * a * b * cos(PI/180 * kaku));

  cout << fixed << setprecision(9) << ans << endl;

  return 0;
}


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

long long int llNum[10000];

int insert_sort(long long int llNum[], int iLen)
{
    for (int i = 1; i < iLen; i++)
    {
        long long int llVal = llNum[i];
        int j = i - 1;
        
        while ((j >= 0) && (llNum[j] > llVal))
        {
            llNum[j + 1] = llNum[j];
            j--;
        }
        
        llNum[j + 1] = llVal;
    }
    
    return 0;
}

int main()
{
    unsigned int uiSize = 0;
    long long int llSum = 0;
    
    cin >> uiSize;
    
    for (int i = 0; i < uiSize; i++)
    {
        cin >> llNum[i];
        llSum += llNum[i];
    }
    
    insert_sort(llNum, uiSize);
    
    cout << llNum[0] << " " << llNum[uiSize - 1] << " " << llSum << endl;
    
    return 0;
}



Measured memory_bytes: 3168
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i(0);i<n;i++)
typedef long long ll;

using namespace std;

int main(){
	
	long H(0);
    int N(0);
    cin >> H >> N;
    //vector<int> A;
    long cnt(0);
    rep(i,N){
        int a;
        cin >> a;
        cnt +=a;
    }

    if(H > cnt) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

using namespace std;
using ll = long long;

int main(){
    int a,b;
    cin>>a>>b;
    if(a==b) cout<<"Draw"<<endl;
    else if(a != 1 && b != 1){
        if(a > b) cout<<"Alice"<<endl;
        else cout<<"Bob"<<endl;
    }
    else if(a == 1) cout<<"Alice"<<endl;
    else cout<<"Bob"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
#define MAX 25
 
struct Node{
  int parent;
  int left;
  int right;
};
 
struct Node T[MAX];
 
void preP(int);
void inP(int);
void postP(int);
 
int main(){
  int i=0;
  int n=0;
  int id=0;
  int root=0;
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    T[i].parent=-1;
  }
 
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&T[id].left,&T[id].right);
    if(T[id].left!=-1)T[T[id].left].parent=id;
    if(T[id].right!=-1)T[T[id].right].parent=id;
  }
 
  for(i=0;i<n;i++) if(T[i].parent==-1) root=i;
 
  printf("Preorder\n");
  preP(root);
  printf("\n");
  printf("Inorder\n");
  inP(root);
  printf("\n");
  printf("Postorder\n");
  postP(root);
  printf("\n");
 
  return 0;
}
 
 
void preP(int u){
  if(u==-1) return;
  printf(" %d",u);
  preP(T[u].left);
  preP(T[u].right);
}
 
void inP(int u){
  if(u==-1) return;
  inP(T[u].left);
  printf(" %d",u);
  inP(T[u].right);
}
 
void postP(int u){
  if(u==-1) return;
  postP(T[u].left);
  postP(T[u].right);
  printf(" %d",u);
}



Measured memory_bytes: 2096
package main

import (
	"fmt"
	"sort"
)

type Event struct {
	time int
	channel int
	start bool
}

type EventSorter []Event

func (events EventSorter) Len() int {
	return len(events)
}

func (events EventSorter) Less(i, j int) bool {
	if events[i].time != events[j].time {
		return events[i].time < events[j].time
	}
	return events[i].start && !events[j].start
}

func (events EventSorter) Swap(i, j int) {
	events[i], events[j] = events[j], events[i]
}

func main() {
	var numPrograms, numChannels int
	fmt.Scanf("%d%d", &numPrograms, &numChannels)

	var events []Event
	for i := 0; i < numPrograms; i++ {
		var s, t, c int
		fmt.Scanf("%d%d%d", &s, &t, &c)
		events = append(events, Event{s, c - 1, true})
		events = append(events, Event{t, c - 1, false})
	}

	sort.Sort(EventSorter(events))

	recording := make([]int, numChannels)
	needed := 0

	for _, e := range events {
		if e.start {
			recording[e.channel]++
		} else {
			recording[e.channel]--
		}

		count := 0
		for _, r := range recording {
			if r > 0 {
				count++
			}
		}
		if count > needed {
			needed = count
		}
	}

	fmt.Println(needed)
}


Measured memory_bytes: 23424
#include <bits/stdc++.h>
#define NIL -1
#define MAX 10000

using namespace std;

struct Node {
  int parent, left, right;
};

Node Nodes[MAX];
int n, Depth[MAX], Height[MAX];

int setHeight(int id) {
  int h1 = 0, h2 = 0;
  if (Nodes[id].left != NIL) {
    h1 = setHeight(Nodes[id].left) + 1;
  }
  if (Nodes[id].right != NIL) {
    h2 = setHeight(Nodes[id].right) + 1;
  }
  return Height[id] = max(h1, h2);
}

void setDepth(int id, int depth) {
  if (id == NIL) return;
  Depth[id] = depth;
  setDepth(Nodes[id].left, depth + 1);
  setDepth(Nodes[id].right, depth + 1);
}

int getSibling(int id) {
  int parent_id = Nodes[id].parent;
  Node parent = Nodes[parent_id];
  if (parent_id == NIL) return NIL;
  if (parent.left != id) return parent.left;
  if (parent.right != id) return parent.right;
}

int getDegree(int id) {
  int degree = 0;
  if (Nodes[id].left != NIL) degree++;
  if (Nodes[id].right != NIL) degree++;
  return degree;
}

string getType(int id) {
  Node node = Nodes[id];
  if (node.parent == NIL) {
    return "root";
  }
  else if (node.left == NIL && node.right == NIL) {
    return "leaf";
  } else {
    return "internal node";
  }
}

void print(int id) {
  printf("node %d: ", id);
  printf("parent = %d, ", Nodes[id].parent);
  printf("sibling = %d, ", getSibling(id));
  printf("degree = %d, ", getDegree(id));
  printf("depth = %d, ", Depth[id]);
  printf("height = %d, ", Height[id]);
  printf("%s\n", getType(id).c_str());
}

int getRoot() {
  for (int i = 0; i < (int)(sizeof(Nodes)/sizeof(Nodes[0])); i++) {
    if (Nodes[i].parent == NIL) return i;
  }
}

int main() {
  int nodes; cin >> nodes;
  for (int i = 0; i < nodes; i++) {
    Nodes[i].parent = -1;
  }
  for (int i = 0; i < nodes; i++) {
    int id, left, right;
    cin >> id >> left >> right;
    Nodes[id].left = left;
    Nodes[id].right = right;
    if (left != NIL) Nodes[left].parent = id;
    if (right != NIL) Nodes[right].parent = id;
  }

  int root = getRoot();
  setHeight(root);
  setDepth(root, 0);

  for (int i = 0; i < nodes; i++) {
    print(i);
  }

  return 0;
}



Measured memory_bytes: 3268
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<pii>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
 
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}

void solve(){
    int n,k,ans = -inf;
    cin >> n >> k;
    vector<int>p(n+5),c(n+5);
    FOR(i,1,n+1)cin >> p[i];
    FOR(i,1,n+1)cin >> c[i];
    FOR(i,1,n+1){
        bool vis[n+5];
        memset(vis,false,sizeof vis);
        int tot = 0,rem = k,cur = i;
        vector<int>tmp;
        while(!vis[cur] && rem > 0){
            tot += c[p[cur]];
            vis[cur] = 1;
            tmp.pb(cur);
            cur = p[cur];
            ans = max(ans,tot);
            rem--;
        }
        if(!rem)continue;
        int cyc_sum = 0,cyc_siz = 0,j = 0,st = 0;
        while(j < sz(tmp) && tmp[j] != cur)++j;
        st = j;
        while(j < sz(tmp))cyc_sum += c[p[tmp[j]]],cyc_siz++,++j;
        if(cyc_sum <= 0){
            while(rem > 0 && st < sz(tmp)){
                tot += tmp[st];
                ++st;
                ans = max(ans,tot);
                rem--;
            }
        }
        else if(cyc_sum > 0){
            int sum = 0;
            FOR(l,st,sz(tmp)){
                sum += c[p[tmp[l]]];
                int alfa = (rem-l+st-1);
                if(alfa < 0)continue;
                alfa /= cyc_siz;
                if(alfa*cyc_siz+l-st+1 <= rem){
                    ans = max(ans,tot+sum+cyc_sum*alfa);
                }
            }
        }
    }
    cout << ans << "\n";
}
 
signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){
        solve();
        //cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...

Measured memory_bytes: 3796
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
//take care of precedence rule of operators 
//do not forget to change the sizes of arrays and value of contants and other things after debugging  

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define ld long double
#define pi acos(-1.0)
 
#define SZ(x)  (ll)(x.size())
 
//comment the below if not required

/*

#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second
*/
 
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

const ll N = 301;

ll a[N];

int main()
{

    ll t,n,x,A,B,o=1,A1,B1,temp,AA1,BB1,i;

    t=1;

    while(t--)
    {
        cin>>n;

        x=0;
        
        rep(i,1,n+1)
        {
            cin>>a[i];

            if(i>2)
                x^=a[i];
        }

        temp = a[1]+a[2]-x;

        temp = temp/2;


        A = temp;
        B = temp;

        temp = 0;

        if(a[2]<=B)
        {   
            temp += B-a[2];
            B1 = 0;
        }
        else
            B1 = a[2]-B;

        A1 = a[1]-temp-A;

        //Now we need to build odd bits using A1 and B1

        for(i=60;i>=0;--i)
        {
            if((o<<i)&x)
            {
                if((o<<i)<=A1)
                {
                    A1 -= o<<i;
                    A |= o<<i;
                }
                else if((o<<i)<=B1)
                {
                    B1 -= o<<i;
                    B |= o<<i;
                }
                else if((o<<i)<=(A1+B1))
                {
                    A1 -= (o<<i)-B1;
                    B1 = 0;
                    B |= o<<i;
                }
                else
                    break;
            }

        }


        if(((A+B)==(a[1]+a[2])) && A<=a[1] && B>=a[2] && ((A^B^x)==0) && (A>0))
            cout<<(a[1]-A);
        else
            cout<<-1;
    }



    return 0;
}

Measured memory_bytes: 3616
/* dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll ,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,i,j;
	string s;
	cin>>s;
	ll ans=0;
	ll sum=0;
	for(i=0;i<s.size();i++)sum+=(s[i]-'0');
	ans=s[0]-'1';
	ans+=(s.size()-1)*9;
	ans=max(sum,ans);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n;
  int amari;
  double A;
  scanf("%d", &n);
  amari = n % 2;
  A = n / 2;
  if(amari == 0){
    A = (double)A / n;
  }else{
    A++;
    A = (double)A / n;
  }
  printf("%f\n",A);
  return 0;
}

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

int main() {

	string s;
	cin >> s;
	int index = s.length();
	bool flag = true;

	vector<string> substring = {"dream","dreamer","erase","eraser"};

	while(index > 0 && flag) {
		flag = false;
		for(int i = 0; i < substring.size(); ++i) {
			int length = substring[i].length();
			int temp = index - length;
			if(temp < 0) { continue; }
			if(s.substr(temp,length) == substring[i]) {
				index -= length;
				flag = true;
				break;
			}
		}
	}

	if(flag) {
		cout << "YES";
	} else {
		cout << "NO";
	}

	return 0;
}

Measured memory_bytes: 512
# include <stdio.h>

int main(void)
{
  int K, S;
  scanf("%d%d", &K, &S);
  
  int cnt = 0;
  for (int x = 0; x <= K; ++x)
  {
    for (int y = 0; y <= K; ++y)
    {
      int z = S - x - y;
      
      if (0 <= z && z <= K)
      {
        cnt++;
      }
    }
  }
  
  printf("%d\n", cnt);
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
int a[3001][2],i=0;
do{
scanf("%d %d",&a[i][0],&a[i][1]);
i++;
}while(a[i-1][0]!=0||a[i-1][1]!=0);
for(int b=0;b<i-1;b++){
if(a[b][0]<=a[b][1])printf("%d %d\n",a[b][0],a[b][1]);
else if(a[b][0]>a[b][1])printf("%d %d\n",a[b][1],a[b][0]);
}
}

Measured memory_bytes: 1048
x = input()
N = int(x)
A = list(map(int,input().split()))
a = 0
b = 0

for i in range(N-1):
    a = a + A[i+1]

for i in range(N-1):
    b = b + A[i]*a
    a = a - A[i+1]

print(b % (10**9+7))


Measured memory_bytes: 31440
import numpy as np
n,m,x=map(int,input().split())
ca=[list(map(int,input().split())) for i in range(n)]
ca=np.array(ca)
ans=np.array([])
ans_list=np.array([])
for i in range(2**n):
  flag=True
  ans=np.array([0]*(m+1))
  for j in range(n):
    if (i>>j)&1:
      ans+=ca[j]
  for i in range(1,len(ans)):
    if x>ans[i]:
      flag=False
      break
  if flag==True:
    ans_list=np.append(ans_list,ans[0])
if len(ans_list)>=1:
  print(int(min(ans_list)))
else:
  print(-1)

Measured memory_bytes: 27384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

  	int A, B; cin >> A >> B;
    if (A <= 8 and B <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;


int gcd(int a, int b) {
	if (b == 0) return a;

	return gcd(b, a % b);
}
int N = 1e6 + 5;
void solve() {
	int n;
	cin >> n;
	vector<int>v(n);
	map<int,int> m;
	int max_ = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		max_ = max(max_,v[i]);
		m[v[i]]++;
	}
	sort(v.begin(), v.end());
	vector<int> gcdDp(n);

	gcdDp[n-1] = v[n-1];

	for(int i = n-2; i >= 0; i--) {
		int num = gcd(v[i],gcdDp[i+1]);
		gcdDp[i] = num;
	}
	bool flg = true;
	// cout << max_ << endl;
	for(int i = 2; i < N; i++) {
		int c = 0;
		for(int j = i; j < N; j+= i) {
			if(m.find(j) != m.end()) {
				c+= m[j];
			}
			if(c > 1) {
				flg = false;
				break;
			}
		}
		if(c > 1) {
			flg = false;
			break;
		}
	}
	if(flg) {
		cout << "pairwise coprime";
		return;
	}
	if(gcdDp[0] == 1) {
		cout << "setwise coprime";
		return;
	}
	cout << "not coprime";
}

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

	return 0;
}

Measured memory_bytes: 57772
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int A, B, K;
  int count=0;
  int list[100];

  cin >> A >> B >> K;

  for(int i=1; i<1000; i++){
    if((A%i==0) && (B%i==0)){
      count++;
      list[count] = i;
    }
  }

  cout << list[count-(K-1)] << endl;

  return 0;
}


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

int main()
{
cin>>s;
for(int i=0;i<=s.size();i++)
if(s[i]=='7')
{
	cout<<"Yes";
	return 0;
}
cout<<"No";

return 0;

}

Measured memory_bytes: 3596
from sys import stdin
freq = {}
for line in stdin:
    string = line.lower()

    for i in string:
        if i.isalpha():
            freq[i] = freq.get(i, 0) + 1

for char in range(ord('a'), ord('z')+1):
    char = chr(char)
    print('%s : %d' % (char, freq.get(char, 0)))


Measured memory_bytes: 5564
// Code for C - H and V
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

int main() {
  int H, W, K;
  cin >> H >> W >> K;

  vector< string > c(H), v(H);
  REP(i, H) {
    cin >> c[i];
  }

  int total = 0;
  for (int bitH = 0; bitH < (1<<H); ++bitH) {
    vector<int> S;
    REP(i, H) {
      if (bitH & (1<<i)) {
        S.push_back(i);
      }
    }

    for (int bitW = 0; bitW < (1<<W); ++bitW) {
      REP(h, H) {
        v[h] = c[h];
      }

      vector<int> T;
      REP(j, W) {
        if (bitW & (1<<j)) {
          T.push_back(j);
        }
      }

      for (vector<int>::iterator itr = S.begin(); itr != S.end(); itr++) {
        REP(w, W) {
          v[*itr][w] = 'R';
        }
      }

      for (vector<int>::iterator itr = T.begin(); itr != T.end(); itr++) {
        REP(h, H) {
          v[h][*itr] = 'R';
        }
      }

      int cnt = 0;
      REP(w, W) {
        REP(h, H) {
          if (v[h][w] == '#') {
            cnt++;
          }
        }
      }


      if (cnt == K) {
        total++;
      }
    }
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <string.h>

int main() {

  char str[1050] = {0};
  char ch[1050] = {0};
  char mei[30] = {0};
  char pl[1050]={0};
  int i,j,k,l,m,n,o,p;

 
  scanf("%s",str);
  scanf("%d",&n);
   
  for(i=0; i<7 ;i++) {
    ch[i] = str[i];
  }

  j=0;
  o=0;
  k=l=0;

  for ( i = 0; i < n; i++ ){
    scanf("%s", mei);
    scanf("%d %d", &k, &l);
    // printf("mei= %s",mei);
  
    
    if(mei[2] =='p') {
     
      scanf("%s", pl);

      for(m=0;m<l-k+1;m++) {

	//	printf("str[%d]%c = pl[%d]%c\n",m+k,str[m+k] ,m,pl[m]);
	str[m+k] = pl[m];	
      }
    }

    else if(mei[2] == 'v') {
      
      for(m=0; m<strlen(str);m++) {
	ch[m] = str[m];
      }
      
      for(m=0;m<l-k+1;m++) {
	//	printf("str[%d]%c = ch[%d]%c\n",k+m,str[k+m],l-m,ch[l-m]);
	str[k+m] = ch[l-m];
      }
    
    }

    else if(mei[0] = 'p') {   
      
      for(m=k; m<=l;m++) {
	printf("%c" ,str[m]);
      }
      printf("\n");
    }
    
  }

   
  return 0;

}


Measured memory_bytes: 2132
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    AB = [il() for _ in range(N)]
    AB.sort(key=lambda x: x[0])
    ret = 0
    for a, b in AB:
        if M - b > 0:
            ret += b * a
            M = M - b
        else:
            ret += M * a
            break
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 29608
#include<bits/stdc++.h>
#include<iostream>
#include<typeinfo>
#define ll  long long 
#define ull unsigned long long 
#define ld  long double
#define pb  push_back
#define pf  push_front
#define mp  make_pair
#define all(v)  v.begin(),v.end()
#define BP(n)  __builtin_popcount(n)
#define bs(v,x)  binary_search(all(v),x)
#define lb(v,x) lower_bound(all(v),x) //first equal to or lower than element
#define ub(v,x) upper_bound(all(v),x) //first greater than element
#define rep(i,n)  for(i=0;i<n;i++)
#define rep1(j,n)  for (j=i+1;j<n;j++)
#define Unique(v)  vector<int>::iterator it; sort(all(v)); it= unique(all(v)); v.resize(distance(v.begin(),it))
#define M  1000000007
#define PI  acos(-1.0)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
using namespace std;
void input(vector<int>& v,int n){ int i,io; rep(i,n) { cin>>io; v.pb(io);} }
void output(vector<int> v) { int i; rep(i,v.size()) cout<<v.at(i)<<" "; }
map<int,int>  frequency(vector<int> v){ int i; map<int,int> m; rep (i,v.size()) {  if (m.find(v[i])==m.end()) m.insert({v.at(i),1}); else m[v.at(i)]++; } return m; }
bool perfsq(ll n){ return (ceil(sqrt(n))==floor(sqrt(n))); }
bool ispower2(int n) { if (n&(n-1)==0) return true; else return false; }
int string_to_int(string s) { stringstream geek(s); long x = 0; geek >> x; return x; }
bool binary_pred(int a,int b){ return a==b; }
void getans() {
    int x;
    cin >> x;
    if (x == 1)
    	cout<<0<<endl;
    else
    	cout<<1<<endl;
}
int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt", "w", stderr);
    #endif
    int T = 1;
    //cin >> T;
    while (T--) 
        getans();
}
// Check for corner cases
// Check for special case like n = 0 or n = INT_MAX
// Check for Buffer Overflow or use of unsigned variable if any
// Check if problem can be solved mathematically

Measured memory_bytes: 3724
#include<cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<vector>
#include<cmath>
#include<cstdlib>
using namespace std;

typedef long long ll;
const int maxn = 1e5 + 5;
const ll ma = 5e18 + 5;
ll n,k,m,seq[maxn + 5];

struct Point{
	ll x,y;
}a[maxn];

bool cmp(Point A,Point B){
	if(A.x == B.x) return A.y < B.y;
	return A.x < B.x;
}

void Init(){
	scanf("%lld %lld",&n,&k);
	for(ll i = 1;i <= n;i++) scanf("%lld %lld",&a[i].x,&a[i].y);
	sort(a + 1,a + n + 1,cmp);
}

void Insert(ll ny){
	seq[++seq[0]] = ny;
	ll p = seq[0];
	while(p > 1LL && seq[p] < seq[p - 1]) swap(seq[p],seq[p - 1]),p--;
}


int GetW(ll seq[]){
	ll res = ma;
	for(ll i = 1;i <= seq[0];i++){
		if(i + m - 1LL > seq[0]) break;
		res = min(res,seq[i + m - 1LL] - seq[i]);
	}
	return res;
}

void Slove(){
	ll ans = ma;
	m = k;
	a[0].x = a[n + 1].x = ma;
	for(ll i = 1;i <= n - m + 1;i++){
		if(a[i].x == a[i - 1].x) continue;
		ll cnt  = 1;
		seq[0] = 0;
		seq[++seq[0]] = a[i].y;
		for(ll j = i + 1;j <= n;j++){
			Insert(a[j].y);
			cnt++;
			if(cnt >= m && a[j].x < a[j + 1].x){
				ll h = a[j].x - a[i].x;
				ll w = GetW(seq);
				ans = min(ans,h * w);
			}
		}
	}
	if(n == 1) ans = 0;
	printf("%lld\n",ans);
}

int main(){
	Init();
	Slove();
}

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

int main(){
  while(true){
    int n,m;
    cin>>n>>m;
    if(n==0&&m==0){
      break;
    }
    int a[1000];
    for(int i=0;i<n;i++){
      cin>>a[i];
    }
    int sum=-1;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        int p = a[i]+a[j];
        if(p<=m&&p>sum){
          sum=p;
        }
      }
    }
    if(sum!=-1){
      cout<<sum<<endl;
    }else{
      cout<<"NONE"<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3104
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    int[] b=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    long sum=0;
    for(int i=0;i<n;i++){
      sum+=a[i];
    }
    for(int i=1;i<n;i+=2){
      sum-=2*a[i];
    }
    b[0]=(int)sum;
    for(int i=1;i<n;i++){
      b[i]=2*a[i-1]-b[i-1];
    }
    for(int i=0;i<n;i++){
      System.out.println(b[i]);
    }
  }
}

Measured memory_bytes: 69884
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)

ll fun(string a,string &b){
	ll sz=a.size();
	ll ans=0;
	FOR(i,0,sz){
		if(a[i]!=b[i])
			ans++;
	}
	return ans;
}

int main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt	
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	 #endif

    FAST
	//PRECISE

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

ll n=s.size();
ll m=t.size();
ll ans=M;
FOR(i,0,n-m+1){
ans=min(ans,fun(s.substr(i,m),t));
}
cout<<ans;

return 0;
 }

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <bitset>
#include <string>
using namespace std;

int calc(int a, int b, string op){
    if(op == "+") return (a + b) % 256;
    if(op == "-") return (a - b + 256) % 256;
    if(op == "*") return (a * b) % 256;
    if(op == "/") return (a / b) % 256;
    return -1;
}

int main(){
    int m;
    cin >> m;
    map<string, bitset<256> > v;
    for(int i=0; i<m; i++){
        string name;
        int lb, ub;
        cin >> name >> lb >> ub;
        bitset<256> r;
        for(int j=lb; j<=ub; j++){
            r[j] = 1;
        }
        v[name] = r;
    }
    map<string, bool> number;
    for(int i=0; i<256; i++){
        bitset<256> a;
        a[i] = 1;
        v[to_string(i)] = a;
        number[to_string(i)] = true;
    }   

    int n;
    cin >> n;
    stack<string> s;
    bool success = true;
    for(int i=0; i<n; i++){
        string str;
        cin >> str;
        if(!success) continue;
        if(str == "+" || str == "-" || str == "*" || str == "/"){
            string b = s.top();
            s.pop();
            string a = s.top();
            s.pop();
            if(str == "/" && v[b][0]==1){
                success = false;
                continue;
            }
            if(number.count(a)!=0 && number.count(b)!=0){
                s.push(to_string(calc(stoi(a), stoi(b), str)));
            }else{
                bitset<256> newrange;
                string newname;
                if(number.count(a)==0) newname = a;
                else newname = b;
                for(int j=0; j<256; j++){
                    if(v[a][j]==0) continue;
                    for(int k=0; k<256; k++){
                        if(v[b][k]==1) newrange[calc(j, k, str)] = 1;
                    }
                }
                v[newname] = newrange;
                s.push(newname);
            }
        }else{
            s.push(str);
        }   
    }

    if(success){
        cout << "correct" << endl;
    }else{
        cout << "error" << endl;
    }
    return 0;
}



Measured memory_bytes: 3336
#![allow(unused_imports)]

use text_io::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;

fn main() {
    let mut a:usize = read!();
    let mut b:usize = read!();
    let mut c:usize = read!();
    println!("{}",min(a+b,min(b+c,c+a)));
}

Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mk make_pair
#define ft first
#define sc second
#define ppb pop_back
#define sz size
#define forn(i,a,n) for(i=a;i<n;i++)
#define M 1000000007
#define inf 2e18


int main() {


ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
    
ll n,m;
cin>>n>>m;
map<ll,ll> cr,pl;
ll a;
string b;
for(ll i=0;i<m;i++){
    cin>>a>>b;
    // cout<<a<<b<<"\n";
    if(cr[a]==0){
        if(b=="WA")
        pl[a]++;
        else
            cr[a]=1;
    }
}
ll ans1=0,ans2=0;
for(ll i=1;i<=n;i++){
    // cout<<cr[i]<<" "<<pl[i]<<"\n";
    if(cr[i]==1){
        ans1++;
        ans2+=(pl[i]);
    }
}
cout<<ans1<<" "<<ans2;


return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int res,mod,s;
    cin>>s;
    res=s/100;
    mod=s%100;
    //cout<<res<<" "<<mod<<endl;
    if((res>0&&res<=12)&&(mod==0||mod>12))
        cout<<"MMYY"<<endl;
    else if((res==0||res>12)&&(mod>0&&mod<=12))
        cout<<"YYMM"<<endl;
    else if((res>0&&res<=12)&&(mod>0&&mod<=12))
        cout<<"AMBIGUOUS"<<endl;
    else if((res==0||res>12)&&(mod==0||mod>12))
        cout<<"NA"<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
from operator import itemgetter


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

info = [(a[i], b[i]) for i in range(n)]
info = sorted(info, key = itemgetter(1))
for i in range(n):
    a[i], b[i] = info[i]

s = sorted(a)
t = sorted(b)
for i in range(n):
    if s[i] > t[i]:
        print("No")
        exit()

sorted_a = sorted(zip(a, range(len(a))))
graph = [[] for i in range(n)]
for i in range(n):
    u = i
    v = sorted_a[i][1]
    if u != v:
        graph[u].append(v)

used = [False]*n
pos = 0
used[pos] = True
q = deque([pos])
while q:
    pos = q.pop()
    for next_pos in graph[pos]:
        if used[next_pos]:
            continue
        q.append(next_pos)
        used[next_pos] = True

for i in range(n):
    if not used[i]:
        print("Yes")
        exit()

for i in range(n-1):
    if s[i+1] <= t[i]:
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 98320
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {  
  input = myconv(input,3);
  var A = myconv(input[0],6);
  A.sort();
  var B = myconv(input[1],6);
  B.sort();
  B.reverse();
  var tmpA = A.join("");
  var tmpB = B.join("");
  var tmpList = [tmpA,tmpB];
  tmpList.sort();
  if((tmpList[0] == tmpA && tmpList[1] == tmpB) && tmpA != tmpB){
     myout("Yes");
     }else{
      myout("No"); 
     }
}

Main(myin());


Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int H, A;
  cin >> H >> A;
  int answer = 0;
  if(H % A == 0){
    answer = H / A;
  } 
  else{
    answer = H / A + 1;
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int &x:a)
    {
        cin>>x;
    }
    vector<int> dp (n,inf);
    dp[0] = 0;

    for(int i = 0;i<n;i++)
    {
        for(int j=i;j<=i+k;j++)
        {
            if(j<n)
            {
                dp[j] = min(dp[j], dp[i] + abs(a[j]-a[i]));
            }
        }
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long;

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

	for (int i = 0; i < 9; i++) {
		X += N % 10;
		N = N / 10;

	}

	if (Y % X == 0) {
		cout << "Yes" << endl;
		
	}
	else {

		cout << "No" << endl;
	}

}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

  cout<<max(A-2*B,0)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
int main(){
	char dum[101],S[101];
	cin>>dum>>S>>dum;
	cout<<"A"<<S[0]<<"C"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int max = sc.nextInt();
        
        int keta = String.valueOf(max).length();
        
        Set<Integer> set = new TreeSet<Integer>();
        set.add(7);
        set.add(5);
        set.add(3);
        
        for (int i = 0; i < keta - 1; i++) {
            Set<Integer> set2 = new TreeSet<Integer>();
            for (Integer number : set) {
                String str = String.valueOf(number);
                set2.add(Integer.parseInt(str + "7"));
                set2.add(Integer.parseInt(str + "5"));
                set2.add(Integer.parseInt(str + "3"));
            }
            for (Integer number : set2) {
                set.add(number);
            }
        }
        
        int count = 0;
        for (Integer number : set) {
            if (number > max) break;
            
            String str = String.valueOf(number);
            if (str.contains("7") && str.contains("5") && str.contains("3")) count++;
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 36180
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
//#define rem 998244353
#define cont continue
const ll INF=(1ll<<60)-1;//ll ans = 3e18 + 5;
////////////////////////////////////////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*ll tc;
    cin>>tc;
    while(tc--)
    {}*/
    string s;
    cin>>s;
    if( s=="ABC" )
    cout<<"ARC\n";
    else
    cout<<"ABC\n";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
         
        #define mp make_pair
        #define pb push_back
        #define f first
        #define s second
         
        using namespace std;
         
        typedef long long ll;
        const int INF = 1e9;
        const ll INFl = 1e18;
         
        typedef pair<int,int> pii;
        typedef vector<int> vi;
        typedef set<int> si;
        typedef map<int,int> mii;
        typedef unordered_map<int,int> umii;
        typedef queue<int> qi;
         
        vi V;
         
        int main() {
        	ios::sync_with_stdio(false); cin.tie(0);
        	int n; cin >> n;
        	//if (n%10 == 7) cout << "Yes\n";
        	//else cout << "No\n";
        	ll sum = 0;
        	for (int i = 1; i <= n; i ++) {
        		if (i%3 != 0 && i%5 != 0) sum += i;
        	}
        	cout << sum << '\n';
        	return 0;
        }

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;
typedef long long ll;
int g(int a,int b){
	return b?g(b,a%b):a;
}
int main(){
	int n,a,b;
	cin>>n;
	cin>>a;
	for(int i=1;i<n;i++){
		cin>>b;
		a=g(a,b);
	}
	cout<<a<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {

  short n;
  short m = 0;
  cin >> n;
  short p[n];

  for ( short i=0; i<n; i++ )
    cin >> p[i];

  for ( short i=0; i<n; i++) {
    if ( p[i] == i+1 )
      m++;
  }

  if ( m > n-3 )
    cout << "YES" << endl;
  else
	cout << "NO" << endl;

}


Measured memory_bytes: 256
#include<iostream>

int main() {
	int a[4];
	char s[5];
	std::cin >> s;
	for (int i = 0; i < 4; i++) {
		a[i] = s[i] - '0';
	}

	int x;
	for (int i = 0; i < 1 << 3; i++) {
		x = a[0];
		for (int j = 0; j < 3; j++) {
			if ((i & 1 << j) != 0) {
				x += a[j + 1];
			}
			else {
				x -= a[j + 1];
			}
		}
		if (x == 7) {
			printf("%d", a[0]);
			for (int j = 0; j < 3; j++) {
				if ((i & 1 << j) != 0)printf("+");
				else printf("-");
				printf("%d", a[j + 1]);
			}
			printf("=7");
			return 0;
		}
	}
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int total = 0;
    for(int i = 0;i < 2;i++){
        if(a >= b){
            total += a;
            a--;
        }else{
            total += b;
            b--;
        }
    }
    cout << total << endl;
}

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

for i in range(1, N):
    if A[i-1] + A[i] >= L:
        X = i
        break
else:
    print("Impossible")
    exit()

print("Possible")
for i in range(1, X):
    print(i)
for i in range(N-1, X-1, -1):
    print(i)


Measured memory_bytes: 14060
#M-SOLUTIONS D
n = int(input())
a = list(map(int, input().split()))
money = 1000
stocks = 0
signal = 0
for i in range(len(a)-1):
  if signal == 0:
    if a[i+1] > a[i]:
      stocks, money = divmod(money, a[i])
      signal = 1
      #print(i,money,stocks)
  else:
    if a[i+1] < a[i]:
      money += stocks * a[i]
      stocks = 0
      signal = 0
      #print(i,money,stocks)
money += stocks*a[-1]
print(money)

Measured memory_bytes: 9080
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, a, N);
    AIN(ll, b, N);
    ll M = *max_element(ALL(a));
    vector<bool> available(M + 2, false);
    ll r = M + 1;
    ll ans = 0;
    auto ok = [&]() {
        bool ok = true;
        REP(i, N)
        {
            if (a[i] < b[i])
            {
                return false;
            }
            vector<bool> dp(a[i] + 1);
            dp[b[i]] = true;
            for (ll j = b[i] + 1; j <= a[i]; ++j)
            {
                REP1(k, j)
                {
                    if (available[k] && dp[j % k])
                    {
                        dp[j] = true;
                    }
                }
            }
            ok &= dp[a[i]];
        }
        return ok;
    };
    while (r > 0 and not ok())
    {
        ll i;
        for (i = 1; i <= r; ++i)
        {
            available[i] = true;
            if (ok())
            {
                ans += 1LL << i;
                break;
            }
        }
        if (i > r)
        {
            OUT(-1);
            return 0;
        }
        r = i - 1;
        REP1(j, r)
        {
            available[j] = false;
        }
    }
    OUT(ans);
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;



int main(){
    ll X;
    cin >> X;
    ll a=100;
    ll ans=0;
    while(a<X){
        a*=1.01;
        ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3636
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back


using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 1000001;
const int mod = 1000000007;

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

    string ans;

    for(char x : s){
        ans.push_back('A' + (x-'A'+n)%26);
    }

    cout<< ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,k;
vl dp;

int main(){
	cin>>n>>k;
	dp=vl(k+1);
	dp[0]++;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		vl DP(k+1);
		for(int j=1;j<=k;j++) (dp[j]+=dp[j-1])%=mod;
		for(int j=0;j<=k;j++) DP[j]=(dp[j]-(j-x-1>=0?dp[j-x-1]:0)+mod)%mod;
		dp=DP;
	}
	cout<<dp[k]<<endl;
}

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

int main() {
  int N,l,r;
  cin >> N;
  int sum = 0;
  
  for (int i = 0; i < N ; i++){
    cin >> l >> r ;
    sum += r - l + 1;
  }
  
  cout << sum << endl;

}



Measured memory_bytes: 256