akhauriyash/Code-Regression huggingface dataset:
/**
 *      ABC 105 D
 *      author  : kyomukyomupurin
 *      created : 2018-09-16 19:53:32
**/

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

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

    ll N, M; cin >> N >> M;
    ll A[N] = {};
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    ll s[N + 1]; s[0] = 0;
    for (int i = 1; i <= N; ++i) {
        s[i] = A[i - 1] + s[i - 1];
    }

    for (int i = 0; i <= N; ++i) {
        s[i] = s[i] % M;
    }

    sort(s, s + N + 1);
    ll answer = 0;
    ll begin = 0;

    while (begin < N + 1){
        ll end = begin;
        while (end + 1 < N + 1 && s[end + 1] == s[begin]){
            ++end;
        }
        ll len = end - begin + 1;
        if (len >= 2){
            answer += len * (len - 1) / 2;
        }
        begin = end + 1;
    }

    cout << answer << endl;

    return 0;

}

Measured memory_bytes: 1792
def gcd(a,b):
  while b!=0:a,b=b,a%b
  return a
def lcm(a,b):return a*b//gcd(a,b)

def ds(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  return divisors

import random
def is_prime(n):
  if n == 2: return True
  if n == 1 or n & 1 == 0: return False
  d = (n - 1) >> 1
  while d & 1 == 0:
    d >>= 1
  for k in range(100):
    a = random.randint(1, n - 1)
    t = d
    y = pow(a, t, n)
    while t != n - 1 and y != 1 and y != n - 1:
      y = (y * y) % n
      t <<= 1
    if y != n - 1 and t & 1 == 0: return False
  return True

A,B=map(int,input().split())
l=sorted(ds(gcd(A,B)))
n=0
for i in l:
  if is_prime(i)==True:n+=1
print(n+1)

Measured memory_bytes: 4208
#include<iostream>
#include<vector>
#include<algorithm>
typedef long long ll;

using namespace std;

int main()
{ll N,M;
 cin >> N >> M;
 vector<ll> X(M);
 for ( ll i = 0; i < M ; i ++)
 {cin >> X[i];}
 //入力完了
 if(N>=M){cout << 0 << endl;}
   else{sort(X.begin(),X.end());
   vector<ll> Y(M-1);
   for(ll i =0; i < M-1; i ++)
   {Y[i] = X[i+1] - X[i];}
   sort(Y.begin(),Y.end());
   reverse(Y.begin(),Y.end());
   //差分を大きい順に並べた
   ll sum = 0;
    if( N == 1){cout << X[M-1] - X[0];}
        else if ( N>=2){
   for(ll j = 0; j < N - 1;j++)
   { sum += Y[j];}
   
   cout << X[M-1] - X[0] - sum << endl;
 }}
 return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

const int MAX_N = 200000;

int main() {
    int n, a[MAX_N + 1], s[MAX_N + 1] = {}, m = 0;
    vector<int> b = {};
    cin >> n;
    rep(i, n) {
        cin >> a[i+1];
    }

    for(int i = n; i > 0; i--) {
        int cnt = 0;
        for(int j = 2*i; j <= n; j += i) {
            cnt += s[j];
        }
        if(cnt%2 != a[i]) {
            s[i] = 1;
            m++;
            b.push_back(i);
        }
    }

    cout << m << "\n";

    for(auto i : b) {
        cout << i << " ";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  
  vector<int> AC(N+1, 0);
  for( int i = 1; i < N; i++ ){
    if( S.at(i) == 'C' && S.at(i-1) == 'A' ){
      AC.at(i+1) += AC.at(i) + 1;
    }else{
      AC.at(i+1) = AC.at(i);
    }
  }
  
  int A, B;
  for( int i = 0; i < Q; i++ ){
    cin >> A >> B;
    if( A != 1 && S.at(A-1) == 'C' && S.at(A-2) =='A' ){
        cout << AC.at(B)-AC.at(A-1)-1 << endl;
    }else{
      cout << AC.at(B) - AC.at(A-1) << endl;
    }
  }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

int main(){
    LL a,b,c,k;
    cin >> a >> b >> c >> k;
    LL ans=a-b;
    if(k%2) ans=-ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]

ans_num = 1000000
for i in range(2**d):
    bit = format(i,'0'+str(d)+'b')
    score = 0
    ans = 0
    for j in range(d):
        if bit[j] == '1':
            score += pc[j][1] + 100*pc[j][0]*(j+1)
            ans += pc[j][0]
    if score >= g:
        if ans < ans_num:
            ans_num = ans
    else:
        for j in range(d-1, -1, -1):
            if bit[j] == '0':
                p, c = pc[j]
                for k in range(p):
                    score += 100 * (j + 1)
                    ans += 1
                    if score >= g:
                        break
                else:
                    continue
                break
        if score >= g and ans < ans_num:
            ans_num = ans

print(ans_num)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int dp[100001]; int n,a[100001];
int frog(int x)
{
    if(x==1) return 0;
    if(x==2) return abs(a[2]-a[1]);
    if(dp[x]!=-1)
        return dp[x];
    dp[x]=min(frog(x-1)+abs(a[x]-a[x-1]),frog(x-2)+abs(a[x]-a[x-2]));
    return dp[x];
}
int main()
{
    int i,x,y;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    cout<<frog(n)<<endl;
    return 0;
}

Measured memory_bytes: 2560
n, k, q = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

#print(a)
ans = float("inf")
for i in range(n):
    y = a[i]

    c = []
    c_k = []
    for j in range(n):
        if a[j] >= y:
            c_k.append(a[j])
        else:
            c.append(c_k)
            c_k = []
    else:
        c.append(c_k)

    d = []
    for j in c:
        if len(j) >= k:
            j.sort()
            for l in range(len(j)-k+1):
                d.append(j[l])

    if len(d) >= q:
        d.sort()
        ans = min(ans, d[q-1] - d[0])

print(ans)



Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		
		int x = scan.nextInt();
		int y = scan.nextInt();
		int z = scan.nextInt();
		
		System.out.println(z+" "+x+" "+y);
	}

}


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

int main(){
  string s;
  cin >> s;
  int a=s[0]-'0', b=s[1]-'0', c=s[2]-'0', d=s[3]-'0';
  if(a+b+c+d == 7){
    cout << a << '+' << b << '+'<< c << '+' << d << "=7" << endl;
  }
  else if(a+b+c-d == 7){
    cout << a << '+' << b << '+'<< c << '-' << d << "=7" << endl;
  }
  else if(a+b-c+d == 7){
    cout << a << '+' << b << '-'<< c << '+' << d << "=7" << endl;
  }
  else if(a+b-c-d == 7){
    cout << a << '+' << b << '-'<< c << '-' << d << "=7" << endl;
  }
  else if(a-b+c+d == 7){
    cout << a << '-' << b << '+'<< c << '+' << d << "=7" << endl;
  }
  else if(a-b+c-d == 7){
    cout << a << '-' << b << '+'<< c << '-' << d << "=7" << endl;
  }
  else if(a-b-c+d == 7){
    cout << a << '-' << b << '-'<< c << '+' << d << "=7" << endl;
  }
  else if(a-b-c-d == 7){
    cout << a << '-' << b << '-'<< c << '-' << d << "=7" << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
S = [0]*N
for i in range(N):
    S[i] = int(input())

sum_s = sum(S)
if (sum_s%10 != 0):
    print(sum_s)
    exit()
else:
    sort_s = sorted(S)
    for s in sort_s:
        if (s%10 != 0):
            print(sum_s-s)
            exit()

print(0)

Measured memory_bytes: 3060
using System;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = Console.ReadLine();
			var t = Console.ReadLine();

			int count = 0;
			for (int i = 0; i < 3; i++)
			{
				if (s[i].Equals(t[i]))
				{
					count++;
				}
			}
			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 11092
from sys import stdin
    
def calc(s):
    lastA = 0
    firstB = 0
    both = 0
    interAB = 0
    for _s in s:
        if _s[0] == 'B' and _s[-1] == 'A':
            both += 1
        else:
            if _s[0] == 'B':
                firstB += 1
            if _s[-1] == 'A':
                lastA += 1
        
        interAB += _s.count('AB')

    if lastA == 0 and firstB == 0:
        both = max(both-1,0)
    return min(lastA + both, firstB + both) + interAB

def main():
    n = stdin.readline().rstrip()
    s = [x.rstrip() for x in stdin.readlines()]
    ans = calc(s)
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 4340
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

int main() {
    SS(ll,n,k)
    if((n+k)%2==0)p((n+k)/2);
    else{
        p("IMPOSSIBLE");
    }
}

Measured memory_bytes: 256
import sys
 
n = int(input())
links = [set() for _ in range(n)]
for i, line in enumerate(sys.stdin):
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    links[a].add((i, b))
    links[b].add((i, a))
 
ans = [-1] * (n - 1)
k = max(map(len, links))
q = [(0, -1)]
fixed = set()
 
while q:
    v, c = q.pop()
    color = 1
    if c == color:
        color += 1
    for i, u in links[v]:
        if ans[i] != -1:
            continue
        ans[i] = color
        q.append((u, color))
        color += 1
        if c == color:
            color += 1
 
print(k)
print('\n'.join(map(str, ans)))

Measured memory_bytes: 65696
#include<iostream>
#include<algorithm>
#include <string>
#include <cstring>
#include<climits>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
int a[200001];
int d[200001];
stack<int> s;
void go(int x, ll y) {
	if (y == 0) {
		cout << x << '\n'; exit(0);
	}
	int nx = a[x];
	if (nx == x) {
		cout << x << '\n'; exit(0);
	}
	s.push(x);
	if (d[nx] == 0) {
		d[nx] = d[x] + 1;
		go(nx, y - 1);
	}
	else {
		vector<int> v;
		while (!s.empty()) {
			v.push_back(s.top()); 
			if (s.top() == nx)break;
			s.pop();
		}
		y -= 1;
		ll cnt = v.size();
		// 6
		//0 0 0 0 0
		y %= cnt;
		cout << v[v.size() - y - 1] << '\n'; exit(0);
	}
}
//1 - > 3 - > 4 -> 1
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	
	int n;
	ll k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	d[1] = 1;
	s.push(1);
	go(a[1], k - 1);




}

Measured memory_bytes: 6012
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const long long INF = 1LL << 60;

int main(){
  int n=0,k=0,cnt=0;
  cin >> n >> k;
  while(n > 0){
    n/=k;
    cnt++;
  }
  cout << cnt << endl;
}

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

typedef long long ll;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

int main(){

    int N;
    cin >> N;
    if(N % 2 == 0){
        cout << N/2 << endl;
    }else{
        cout << (N+1)/2 << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    int A, W, B;
    cin >> W;
    cin >> A;
    cin >> B;
    int sum = 0;
    if (A > B) {
        int tmp = A;
        A = B;
        B = tmp;
    }
    if (B - (A + W) <= 0) {
        cout << "0" << endl;
    } else {
        cout << B - (A + W) << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define opt ios_base::sync_with_stdio(false); cin.tie(NULL);

void freak__()
{
    int n,k,i,j,msb;
    vector<int> v;
    cin >> n >> k;
    int x,h[10]={0};
    for(i=0;i<k;i++)
    {
        cin >> x;
        h[x]=1;
    }
    for(i=n;i>=n;i++)
    {
        int flag=1;
        x=i;
        while(x)
        {
            if(h[x%10])
            {
                flag=0;
                break;
            }
            x/=10;
        }
        if(flag)
        {
            cout << i;
            break;
        }
    }
    cout << "\n";
}

int main()
{
    opt;
    freak__();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    ll k, q;
    cin >> k >> q;

    ll d[5010];
    for(int i = 0; i < k; i++){
        cin >> d[i];
    }

    for(int i = 0; i < q; i++){
        ll n, x, m;
        cin >> n >> x >> m;
        ll e[5010];
        x %= m;
        ll s = 0;
        ll countZero = 0;
        for(int j = 0; j < k; j++){
            e[j] = d[j] % m;
            s += e[j];
            if(e[j] == 0){
                countZero++;
            }
        }
        x += s * ((n-1) / k);
        countZero *= ((n-1) / k);
        for(int j = 0; j < (n-1) % k; j++){
            x += e[j];
            if(e[j] == 0){
                countZero++;
            }
        }

        cout << n - 1 - x / m - countZero << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define Endl endl

signed main(void){
    string S;
    cin >> S;
    int Ans=0;
    int N=S.size();
    vector<pair<char,int>> E;
    int r=0;
    int M=N;
    REP(i,N){
        if(S[i]=='A'){
            r++;
        }else{
            if(r!=0){
                M-=(r-1);
                E.push_back({'A',r});
            }
            r=0;
            E.push_back({S[i],1});
        }
    }
    
    if(r!=0){
        M-=(r-1);
        E.push_back({'A',r});
    }
    /*
    cout << M << endl;
    cout << E.size() << endl;
    REP(i,M){cout << E[i].first <<" ";}cout << endl;
    REP(i,M){cout << E[i].second <<" ";}cout << endl;
    */
    pair<char,int> T;
    REP(i,M-2){
        if(E[i].first=='A'&&E[i+1].first=='B' && E[i+2].first=='C'){
            T=E[i];
            E[i]=E[i+1];
            E[i+1]=E[i+2];
            E[i+2]=T;
            Ans+=T.second;
            i=max(i-1,0LL);
            i=max(i-1,0LL);
        }
    }
    cout << Ans << endl;
    return 0;
}



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

using namespace std;

string S;

int main(void) {

	cin >> S;

	if (S[2] == S[3] && S[4] == S[5]) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}

Measured memory_bytes: 256
//Author- VMAX


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*
/*
ll prf(ll n)
{
    ll c=0,i;
    while(n%2==0)
    {
        n=n/2;
        c++;
    }
    for(i=3;i*i<=n;i++)
    {
        while(n%i==0)
    }
    
    
    
}
*/
//vector<ll>a(26);
int main()
{
     
      
      ll x,n;
      cin>>x>>n;
      ll i,y;
      
      set<ll>s;
      
      f(i,105)
      {
          s.in(i);
      }
      /*
      fa(i,s)
      {
          o1(i)
      }
      */
      
      f(i,n)
      {
          cin>>y;
          s.erase(y);
      }
      
      ll mn=1e18,p=x;
      fa(i,s)
      { ll zz=abs(x-i);
          if(zz<mn)
          {
              mn=zz;
              p=i;
          }
          
      }
      
      //o(x)
      o(p)
      
      
     

      
  
     re
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<ll,ll> P;

//1. dp,変数
int n,m;
ll c;
//2. 道（辺）と都市（頂点）
vector<P> road[100001];
ll d[200001]={};
ll dp[100001]={};
ll dp2[100001]={};


int main() {
	//3. 入力
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;

	for(int x=sx;x<tx;++x)cout<<"R";
	for(int y=sy;y<ty;++y)cout<<"U";
	for(int x=tx;x>sx;--x)cout<<"L";
	for(int y=ty;y>sy;--y)cout<<"D";
	cout<<"D";
	for(int x=sx;x<tx+1;++x)cout<<"R";
	for(int y=sy;y<ty+1;++y)cout<<"U";
	cout<<"L"<<"U";
	for(int x=tx;x>sx-1;--x)cout<<"L";
	for(int y=ty;y>sy-1;--y)cout<<"D";
	cout<<"R"<<endl;
	return 0;
}


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

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

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


int main(){
    int64_t a,b;
    cin >> a >> b;

    cout << int64_t(lcm(a,b)) << endl;
}

Measured memory_bytes: 256
n = int(input())

cand = []
def rec(n):
  if n > 10**9:
    return
  cand.append(n)
  rec(int(str(n) + "3"))
  rec(int(str(n) + "5"))
  rec(int(str(n) + "7"))
rec(3)
rec(5)
rec(7)
ans = 0

def check(c):
  if "3" in str(c) and "5" in str(c) and "7" in str(c):
    return True
  else:
    return False

for c in cand:
  if c <= n and check(c):
    ans += 1
print(ans)

Measured memory_bytes: 75308
#include<iostream>
#include<cstdlib>
#include<stack>
using namespace std;

int main(){
    stack<long> ST;
    string s;
    long a,b;
    
    while (cin >> s) {
        if (s[0] == '+'){
            a = ST.top(); ST.pop();
            b = ST.top(); ST.pop();
            ST.push(a+b);
        }else if(s[0] == '*'){
            a = ST.top(); ST.pop();
            b = ST.top(); ST.pop();
            ST.push(a*b);
        }else if(s[0] == '-'){
            a = ST.top(); ST.pop();
            b = ST.top(); ST.pop();
            ST.push(b-a);
        }else{
            ST.push(atoi(s.c_str()));
        }
    }
    cout << ST.top() <<endl;
    return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    char a;
    a=1;
    while(true){
        scanf("%c",&a);
        if(a=='\n'){
            break;
        }
        if(a>='a' && a<='z'){
            a=a-32;
        }else if(a>='A' && a<='Z'){
            a=a+32;
        }
        cout<<(char)a;
    }
    cout<<endl;
    return 0;
}

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

#define int long long
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; i++)
#define MOD (int)(1e9+7)
using namespace std;
typedef pair<int, int> P;
struct edge {
    int to, cost;
};

class dijkstra {
private:
    int V;
    int d[100002];
    priority_queue<P, vector<P>, greater<>> que;

public:
    dijkstra(int v, int s, vector<edge> G[]) {
        V = v;
        update(s, G);
    }

    void update(int s, vector<edge> G[]) {
        fill(d, d + V + 1, 100000000000ll);
        d[s] = 0;
        que.push(make_pair(0, s));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (d[v] < p.first)
                continue;
            rep(i, G[v].size()) {
                edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(make_pair(d[e.to], e.to));
                }
            }
        }
    }

    int find(int e) {
        return d[e];
    }
};

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

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

bool prime(int a) {
    if (a == 1)
        return false;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0)
            return false;
    }
    return true;
}

class Union_Find {
private:
    vector<int> t, s;

public:
    Union_Find(int max_length) {
        rep(i, max_length + 1) {
            t.push_back(i);
            s.push_back(1);
        }
    }

    void Union(int x, int y) {
        if (same(x, y))
            return;
        int tx = Find(x), ty = Find(y);
        if (s[tx] < s[ty]) {
            s[ty] += s[tx];
            t[tx] = ty;
        } else if (s[tx] > s[ty]) {
            s[tx] += s[ty];
            t[ty] = tx;
        } else if (tx > ty) {
            t[tx] = ty;
            s[ty] += s[tx];
        } else {
            t[ty] = tx;
            s[tx] += s[ty];
        }
    }

    int Find(int n) {
        if (t[n] == n)
            return n;
        else
            return t[n] = Find(t[n]);
    }

    bool same(int x, int y) {
        return Find(x) == Find(y);
    }

    int get_Size(int a) {
        return s[a];
    }
};

vector<int> primeFactorization(int n) {
    vector<int> re;
    int cnt = 2;
    while (n != 1) {
        if (n % cnt != 0) {
            cnt++;
            continue;
        }
        n /= cnt;
        re.push_back(cnt);
    }
    return re;
}

signed main() {
    int n,d,x[10][10];
    cin>>n>>d;
    rep(i,n){
        rep(j,d){
            cin>>x[i][j];
        }
    }
    int ans=0;
    rep(i,n){
        rep(j,i){
            int cnt=0;
            rep(k,d)cnt+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            if(cnt==(int)sqrt(cnt)*(int)sqrt(cnt))ans++;
        }
    }
    cout<<ans<<endl;
}


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("fibsubseq.in","r",stdin)
#define write()         freopen("fibsubseq.out","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long int
#define endll           pf("\n")
#define pf              printf
#define pi              acos(-1.0)
#define eps             1e-10
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())

bool Check(unsigned int  N,int pos){return (bool)(N & (1LL<<pos));}
ll  Set(unsigned int N,int pos){    return N=N | (1LL<<pos);}
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define mod  1000000007
#define mod1 1000000009
#define var    int ii,i,j,n,k,m,z=0,c=0,t,x,y,l,r,mid
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

ll a[100005],dp[105][100008],b[100005];

ll fn(ll pos,ll n,ll v)
{
    if(pos==n+1)
    {
        if(v==0)return 0;
        return 1e16;
    }
    ll &z=dp[pos][v];
    if(z!=-1)return z;
    z=1e16;
    z=min(z,a[pos]+fn(pos+1,n,v-b[pos]));
    z=min(z,fn(pos+1,n,v));
    return z;
}

int main()
{
    SPEED;
    ll var;
    mem(dp,-1);
    sfl(n);sfl(m);
    for(i=1;i<=n;i++)
    {
        sfl(a[i]);sfl(b[i]);

    }
    for(i=100000;i>=1;i--)
    {
        z=fn(1,n,i);
        c=i;
        if(z<=m)break;
    }
    cout<<c<<endl;
}


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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep1(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p)
{
    return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc)
{
    o << "sz = " << vc.size() << endl
      << "[";
    for (const T& v : vc)
        o << v << ",";
    o << "]";
    return o;
}
using ll = long long;
constexpr ll MOD = 1000000007;

int main()
{

    int n;
    cin >> n;
    vector<int> s(n);
    int sum = 0;
    rep(i, n)
    {
        cin >> s[i];
        sum += s[i];
    }
    if (sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }

    sort(s.begin(), s.end());
    for (int i = 0; i < n; i++) {
        if (s[i] % 10 != 0) {
            cout << sum - s[i] << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
    int n;

    cin >> n;
    vector<int> a;

    for(int i=0; i<n; i++){
        int input_a;
        cin >> input_a;
        if (i % 2 == 0) a.push_back(input_a);
        else a.insert(a.begin(),input_a);
    }

    if (n %2 == 1)reverse(a.begin(), a.end());

    ostringstream ss;

    for(int i=0; i<n; i++){
        if(i!=0) ss << " ";
        ss << a[i];
    }

    cout << ss.str();

    return 0;
}

Measured memory_bytes: 6904
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include "bits/stdc++.h"

#define fastio  	ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
#define TC      	int t; cin >> t; for(int tc = 1; tc <= t; tc++)
#define read    	freopen("input.txt", "r", stdin);
#define write   	freopen("output.txt", "w", stdout);
#define nl      	'\n'
#define pii			pair<int, int>
#define ll 			long long
#define pb			push_back
#define eb			emplace_back
#define all(v)		v.begin(), v.end()
#define rall(v)		v.rbegin(), v.rend()
#define d(x)		cerr << #x << " = " << x << nl


using namespace std;


int main() {
	/*
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    */
		int d, t, s;
		cin >> d >> t >> s;
		if(t*s >= d) cout << "Yes";
		else cout << "No";
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const double PI = 3.14159265358979323846;
template <class T, class U>
void chmin(T& t, const U& u) {
  if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
  if (t < u) t = u;
}

int main(void) {
  int n;
  cin >> n;
  ll a = 1, b = 1, c = 1;
  rep(i, n) {
    a *= 10;
    b *= 9;
    c *= 8;
    a %= MOD;
    b %= MOD;
    c %= MOD;
  }
  ll res = (a % MOD) + (c % MOD) - ((2LL * b) % MOD);
  if (res < 0) res += MOD;
  res %= MOD;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
int main(){
	int a,b,r=0;double x=0,y=0;
	while(scanf("%d,%d",&a,&b),a||b){
		x+=a*cos(r*M_PI/180.0);
		y+=a*sin(r*M_PI/180.0);
		r+=b;
	}
	printf("%d\n%d\n",(int)y,(int)x);
}

Measured memory_bytes: 1192
#!/usr/bin/env python3
import sys
import numpy as np

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, S: str):
    if N%2==0:
        N//=2
        if S[N:]==S[:N]:
            print(YES)
        else:
            print(NO)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12432
#include<stdio.h>
#define MAX 100000+5
#define NIL -1

typedef struct Node{
  int left;
  int right;
  int parent;
}T;

T Tree[MAX];

void Preorder(int);
void Inorder(int);
void Postorder(int);

int main(){
  int n, i;
  int id,left,right,root;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    Tree[i].parent = NIL;
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d %d %d",&id, &left, &right);
    Tree[id].left = left;
    Tree[id].right = right;
    if(left != NIL) Tree[left].parent = id;
    if(right != NIL) Tree[right].parent = id;
  }

  for(i = 0 ; i < n ; i++) if(Tree[i].parent == NIL) root = i;

  printf("Preorder\n");
  Preorder(root);
  printf("\n");

  printf("Inorder\n");
  Inorder(root);
  printf("\n");

  printf("Postorder\n");
  Postorder(root);
  printf("\n");

  return 0;
}

void Preorder(int x){
  if(x == NIL) return;
  printf(" %d",x);
  Preorder(Tree[x].left);
  Preorder(Tree[x].right);
}

void Inorder(int x){
  if(x == NIL) return;
  Inorder(Tree[x].left);
  printf(" %d",x);
  Inorder(Tree[x].right);
}

void Postorder(int x){
  if(x == NIL) return;
  Postorder(Tree[x].left);
  Postorder(Tree[x].right);
  printf(" %d",x);
}



Measured memory_bytes: 2052
#include <iostream>
#include <set>
#include <math.h>
#include <list>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX_N 10005
#define MAX_M 100

int N;
int A[MAX_N];

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(C, B / A) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n1,n2,n3,n4;
bool o1,o2,o3,o4;
int main()
{
	cin>>n1>>n2>>n3>>n4;
	if(n1==1 || n2==1 || n3==1 || n4==1)
	{
		o1=true;
	}
	if(n1==9 || n2==9 || n3==9 || n4==9)
	{
		o2=true;
	}
	if(n1==7 || n2==7 || n3==7 || n4==7)
	{
		o3=true;
	}
	if(n1==4 || n2==4 || n3==4 || n4==4)
	{
		o4=true;
	}
	if(o1 && o2 && o3 && o4)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using tp = tuple<ll,ll,ll>;
ll n,m,s;
ll a,b; 
ll c[55],d[55];       //存获得的银币和消耗的时间 
ll dp[55][2505];            //到达i时还有j银币的最小时间 
vector<tp> G[55];          //目标点 a b 
tp info;              //时间 目标点 当前的钱 
const ll inf = 0x3f3f3f3f3f3f3f3f;
int main(){
	cin>>n>>m>>s;
	s = min(s,2504LL);
	for(ll i=0;i<m;i++){
		ll ta,tb,tc,td;
		cin>>ta>>tb>>tc>>td;
		G[ta].push_back(tp(tb,tc,td));
		G[tb].push_back(tp(ta,tc,td));	 
	}
	for(ll i=1;i<=n;i++){
		ll tc,td;
		cin>>tc>>td;
		c[i] = tc;
		d[i] = td;
	}
	fill(dp[0] , dp[0] + 54*2504 , inf);
	dp[1][s] = 0;
	priority_queue<tp,vector<tp>,greater<tp>> pq;
	pq.push(tp(0,1,s));
	while(!pq.empty()){
		info = pq.top();
		pq.pop();
		ll t = get<0>(info) , u = get<1>(info) , w = get<2>(info);
		if(dp[u][w] > t) continue;
		for(auto i:G[u]){
			ll v = get<0>(i) , aa = get<1>(i) , bb = get<2>(i);
			if(w>=aa and dp[v][w-aa] > t + bb){
				dp[v][w-aa] = t + bb;
				pq.push(tp(t+bb , v , w-aa));
			}
		}
		if(dp[u][min(w + c[u] , 2504LL)] > t + d[u]){
			dp[u][min(w + c[u] , 2504LL)] = t + d[u];
			pq.push(tp(t + d[u] , u , min(w + c[u] , 2504LL)));
		}
		
	
	}	
	
	for(ll i=2;i<=n;i++){
			ll ans = inf;
			for(ll j=0;j<2504;j++){
				ans = min(ans , dp[i][j]);
			}
			cout<<ans<<endl;
		}
	
	return 0;
}







Measured memory_bytes: 7368
from collections import*

def searchnode(i,u,path):  #つなげるものの個数の確認
    r = 1 
    u[i] = 1
#    print(u)
    for j in range(26):
        if path[(i,j)] and (not u[j]):
            r += searchnode(j,u,path)
    return r

def chrtoint(a):
    return ord(a)-ord('a')

while 1:
    n = int(input())
    if n==0:
        break
    inp=[input()for i in range(n)]
    front,back = [0]*26,[0]*26
    path = defaultdict(int)
    u = [0]*26

    for i in inp:
        front[chrtoint(i[0])] += 1
        back[chrtoint(i[-1])] += 1
        path[(chrtoint(i[0]),chrtoint(i[-1]))] += 1

#    print(path)
    if front!=back:
        print("NG")
        continue
    if sum(i!=0 for i in front) == searchnode(chrtoint(i[-1]),u,path):
        print("OK")
    else:
        print("NG")


Measured memory_bytes: 7272
// 2014/09/12 Tazoe

#include <iostream>
#include <queue>
#include <string>
#include <map>
using namespace std;

struct state{
	string G;
	int N;
};

bool is_over(string G)
{
	bool flg = true;

	for(int i=1; i<G.size(); i++){
		if(G[i]!=G[0]){
			flg = false;
			break;
		}
	}

	return flg;
}

void DFS(char g[12][12], char F, char T, int x, int y)
{
	if(g[y][x]!=F)
		return;

	g[y][x] = T;

	DFS(g, F, T, x-1, y);
	DFS(g, F, T, x+1, y);
	DFS(g, F, T, x, y-1);
	DFS(g, F, T, x, y+1);
}

string fill(string G, char C, int X, int Y)
{
	char g[12][12];
	for(int y=0; y<Y+2; y++){
		for(int x=0; x<X+2; x++){
			g[y][x] = 'N';
		}
	}

	// 文字列から2次元配列へ
	for(int y=0; y<Y; y++){
		for(int x=0; x<X; x++){
			g[y+1][x+1] = G[y*X+x];
		}
	}

	DFS(g, G[0], C, 1, 1);

	// 2次元配列から文字列へ
	for(int y=0; y<Y; y++){
		for(int x=0; x<X; x++){
			G[y*X+x] = g[y+1][x+1];
		}
	}

	return G;
}

int main()
{
	while(true){
		int X, Y;
		cin >> X >> Y;

		if(X==0 && Y==0)
			break;

		string G = "";
		for(int y=0; y<Y; y++){
			for(int x=0; x<X; x++){
				string c;
				cin >> c;

				G += c;
			}
		}

		queue<struct state> que;
		map<string, bool> memo;

		struct state now;
		now.G = G;
		now.N = 0;
		que.push(now);
		memo[now.G] = true;

		while(!que.empty()){
			now = que.front();
			que.pop();

			if(is_over(now.G)){
				cout << now.N << endl;
				break;
			}

			struct state nex1, nex2;

			if(now.G[0]=='R'){
				nex1.G = fill(now.G, 'G', X, Y);
				nex2.G = fill(now.G, 'B', X, Y);
				nex1.N = nex2.N = now.N+1;
			}
			else if(now.G[0]=='G'){
				nex1.G = fill(now.G, 'R', X, Y);
				nex2.G = fill(now.G, 'B', X, Y);
				nex1.N = nex2.N = now.N+1;
			}
			else if(now.G[0]=='B'){
				nex1.G = fill(now.G, 'R', X, Y);
				nex2.G = fill(now.G, 'G', X, Y);
				nex1.N = nex2.N = now.N+1;
			}

			if(memo.find(nex1.G)==memo.end()){
				que.push(nex1);
				memo[nex1.G] = true;
			}
			if(memo.find(nex2.G)==memo.end()){
				que.push(nex2);
				memo[nex2.G] = true;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2564
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,ll> P;
typedef vector<P> vip;

void solve(){
    char a,b;cin>>a>>b;
    if (a==b){
        cout << "="<<endl;
    }else{
        cout << (a<b?"<":">")<<endl;
    }
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<double,double>;
using node = tuple<int, int, int>;
const int MAX_N = 500000;
const double inf = numeric_limits<double>::max()/3;
const ll mod = 1e9+7;

int main(void){
  int n;
  cin >> n;
  map<ll,int> m;
  for(int i = 0;i < n;++i){
    ll a;
    cin >> a;
    m[a]++;
  }
  int res = 0;
  for(auto p : m){
    if(p.second < p.first)
      res += p.second;
    else
      res += p.second - p.first;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 6272
#include <iostream> // {{{
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <cstdio> // }}}

#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,s,n) for(int i=s; i<n; i++)

using namespace std;

int main() {
    string s,t,ans;
    cin >> s >> t;

    int ss,ts,sub;
    ss = s.size();
    ts = t.size();
    sub = ss - ts;
    bool match;
    for (int i=sub; i>=0; i--) {
        match = true;
        for (int j=0; j<ts; j++) {
            if (s[i+j] != '?' && s[i+j] != t[j]) {
                match = false;
                break;
            }
        }
        if (match) {
            for (int j=0; j<ts; j++) {
                s[i+j] = t[j];
            }
            break;
        }
    }
    if (!match) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
  for (int i=0; i<ss; i++) {
        if (s[i] == '?') {
            s[i] = 'a';
        }
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,c,x=0,i;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0){
            x++;
        }
    }
    printf("%d\n",x);
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  ll cnt=0;
  rep(i,N)cin>>a[i];
  rep(i,N){
    if(i%2==1)continue;
    if(a[i]%2==0)continue;
    cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3576
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    n=int(input())
    for i in range(10**10):
        if i**2>n:
            break
    print((i-1)**2)


resolve()

Measured memory_bytes: 38512
x = input()
a = list(map(int, input().split()))

c = 0

while True:
  f = False
  for i in a:
    if i % 2 == 1:
      f = True
  if f == True:
    break

  for index, i in enumerate(a):
    a[index] /= 2

  c += 1

print(c)

Measured memory_bytes: 2940
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int n,a,ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++)v.push_back(-1);
     for(int i=0;i<n;i++){
         cin>>a;
         int p=lower_bound(v.begin(),v.end(),a)-v.begin();
         if(v[p-1]==-1)ans++;
         v[p-1]=a;
     }
     cout<<ans<<endl;
}


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

int main(void)
{
    long long N, M;
    cin >> N >> M;
    vector<pair<long long, long long>> A(N);
    for (long long i = 0; i < N; i++)
    {
        long long a;
        cin >> a;
        A[i] = make_pair(a, 1);
    }
    for (long long i = 0; i < M; i++)
    {
        long long b, c;
        cin >> b >> c;
        A.push_back(make_pair(c, b));

    }

    sort(A.begin(), A.end());

    long long ans = 0;
    long long i = A.size() - 1;
    long long x = 0;
    while(1)
    {
        if(x + A[i].second > N)
        {
            ans += A[i].first * (N - x);
            break;
        }
        ans += A[i].first * A[i].second;
        x += A[i].second;
        i--; 
    }
    cout << ans << endl;
}

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

int main(){
	string input;
	cin >> input;
	int n;
	cin >> n;
	string order, replace;
	int a, b;

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

		if(order == "print"){
				cin >> a >> b;
				for(int s=a; s<=b; s++){
					cout << input[s];
				}
				cout << endl;
		} else if (order == "replace"){
				cin >> a >> b >> replace;
				for(int s=0; s<(b-a+1); s++){
					input[a+s] = replace[s];
				}
		} else if (order == "reverse"){
				cin >> a >> b;
				string temp = input;
				for(int s=0; s<(b-a+1); s++){
					input[a+s] = temp[b-s];
				}
		}

	}

	return 0;
}

Measured memory_bytes: 3168
#include<stdio.h>
int main(){
int n,i;
scanf("%d\n",&n);
for(i=3;i<=n;i++){
	if(i%10==3 || i%100/10==3 || i%1000/100==3 ||i%10000/1000==3 || i%3==0){
	printf(" %d",i);
	}
}
printf("\n");
return 0;
}

Measured memory_bytes: 604
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n,t,s,e = LI()
    s -= 1
    e -= 1
    v = [[] for i in range(n)]
    f = [0]*n
    for i in range(n-1):
        a,b,w = LI()
        a -= 1
        b -= 1
        v[a].append((b,w))
        v[b].append((a,w))
        f[a] += 1
        f[b] += 1

    bfs = [1]*n
    bfs[s] = 0
    q = deque([s])
    par = [None]*n
    while q:
        x = q.popleft()
        for y,w in v[x]:
            if bfs[y]:
                par[y] = [x,w-t*(f[x]-1)]
                bfs[y] = 0
                q.append(y)
    path = [0]*n
    while e != s:
        path[e] = 1
        e = par[e][0]
    bfs = [1]*n
    bfs[s] = 0
    q = deque([s])
    child = [[] for i in range(n)]
    while q:
        x = q.popleft()
        for y,w in v[x]:
            if bfs[y]:
                if not path[y]:
                    child[x].append(w-t*(f[y]-1))
                bfs[y] = 0
                q.append(y)
    for x in range(n):
        if path[x]:
            if par[x][1] <= 0:
                print("No")
                return
        child[x].sort()
        for i in range(len(child[x])):
            child[x][i] -= t*(i+1)
            if child[x][i] <= 0:
                print("No")
                return
    print("Yes")
    return

if __name__ == "__main__":
    solve()



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

int main(){
    int h, w;
    cin >> h >> w;
    
    vector<char> b(w);
    
    string fold;
    string line;
    
    for(int i = 0; i < w+2; i++){
        fold += '#';
    }
    
    while(h != 0){
        
        line += '#';
        for(int i = 0; i < w; i++){
            cin >> b.at(i);
            line += b.at(i);
        }
        line += '#';
        line += '\n';

        h--;
    }
    cout << fold << endl;
    cout << line;
    cout << fold << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,T;
void input(){
    fast_io();
    cin >> N >> T;
    int ans = INT_INF;
    for (int i = 0; i < N; i++)
    {
        int c,t; cin >> c >> t;
        if(t>T) continue;
        ans = min(ans,c);
    }
    if(ans==INT_INF) cout << "TLE" << endl;
    else cout << ans << endl;
}

int solve(){
    return 0;
}   

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

Measured memory_bytes: 256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cctype>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

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

  string n = to_string(N);

  if(n[0] == n[2]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
a = input()
a = int(a)
s = a%60
m = (a-a%60)/60%60
h = (a-s-m*60)/3600
m = int(m)
h = int(h)
s=str(s)
m=str(m)
h=str(h)
print(h + ':'+m+':'+s)

Measured memory_bytes: 6736