akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
inline void putint(ll X) {
	int keta = 0;
	char C[20];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) putchar(*(C + i));
	putchar('\n');
}

int N;
ll D[100001];
vector<pair<int, int>> E[100001];
void dfs(int A, ll B) {
	*(D + A) = B;
	for (auto itr = (*(E + A)).begin(); itr != (*(E + A)).end(); itr++) if (!(*(D + (*itr).first))) dfs((*itr).first, B + (*itr).second);
}

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


	int N = getint();
	rep(i, N - 1) {
		int a = getint();
		int b = getint();
		int c = getint();
		(*(E + a)).pb(mp(b, c));
		(*(E + b)).pb(mp(a, c));
	}
	int Q = getint();
	int K = getint();
	dfs(K, 1);
	rep(i, Q) {
		int x = getint();
		int y = getint();
		putint(*(D + x) + *(D + y) - 2);
	}

	Would you please return 0;
}

Measured memory_bytes: 11392
def allzero(h):
    for i in range(N):
        if h[i] != 0:
            return False
    return True

def move(i):
    if i == N:
        return 0

    for k in range(i, N):
        if h[k] != 0:
            return k
    return 0

N = int(input())
h = list(map(int,input().split()))
i = 0
j = 0
cnt = 0
while not allzero(h):
    while i < N and h[i] != 0:
        h[i] -= 1
        i += 1
    if i != 0:
        cnt += 1
    i = move(i)
print(str(cnt))

Measured memory_bytes: 3064
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int n;
    n=in.nextInt();
    int ac=0,wa=0,tle=0,re=0;
    for(int i=1;i<=n;i++)
    {
      String s=in.next();
      if(s.compareTo("AC")==0)
      {
        ac++;
      }
      else if(s.compareTo("TLE")==0)
      {
        tle++;
      }
      else if(s.compareTo("WA")==0)
      {
        wa++;
      }
      else
      {
        re++;
      }
    }
      System.out.println("AC x "+ac);
      System.out.println("WA x "+wa);
      System.out.println("TLE x "+tle);
      System.out.println("RE x "+re);
  }
}

Measured memory_bytes: 58696
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
//#include <cmath>
#include <cstdlib>

using namespace std;

int main(){

    int n;
    cin >> n ;

    vector<int> b(0);

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

    if(n%2 == 0){
        for(int i=0;i<n;i++) cout << b[n-1-i] << " ";
    }else{
        for(int i=0;i<n;i++) cout << b[i] << " ";
    }
    return 0;
}

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

using namespace std;

const int MAXN = 55555;

int arr[5*MAXN+1];

vector<int> prime;
vector<int> ans;

int f()
{
	for(int i=prime.size()-1;i>=4;i--)
		for(int j=i-1;j>=3;j--)
			for(int k=j-1;k>=2;k--)
				for(int r=k-1;r>=1;r--)
					for(int p=r-1;p>=0;p--)
					{
						int sum = prime[i]+prime[j]+prime[k]+prime[r]+prime[p];
						if(!arr[sum]){
							printf("%d ",prime[i]);
							return 0;	
						}
						
					}
	return 1;
}

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=2;i*i<=MAXN*5;i++)
		for(int j=i*i;j<=MAXN*5;j+=i)
			arr[j] = 1;
		
	
	
	int cnt =0;
	for(int i=6;i<=MAXN;i+=5)
		if(!arr[i]){
			prime.push_back(i);
			
			if(prime.size()>=n)break;
		}
	for(int i=0;i<n;i++)printf("%d ",prime[i]);

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
#define  st first
#define  nd second
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
 
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
 
 
#define MOD   1000000007
const int LN =19;
#define int long long
const int  MAXN = 4001;
 
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef cc_hash_table<int, int, hash<int > > ht;
int sum[3][MAXN] ; 
int dp[3][MAXN][MAXN];
int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int n ; 
  cin >> n ; 
  string s ; 
  cin >> s ; 
  int a[n] ; 
  for(int i = 0 ; i< n ; i++) {
      if(s[i]=='R'){
        a[i]=0;
      }
      else if(s[i]=='G'){
          a[i]=1;
      }
      else{
          a[i]=2;
      }
  }
  dp[a[n-1]][n-1][n-1]++;
  sum[a[n-1]][n-1]++;
 //dbg_ok;
  for(int i = n-2 ; i>=0 ; i--){
      for(int j = 0 ; j < n ; j++){
          for(int k = 0 ; k<3 ; k++){
              dp[k][i][j] = dp[k][i+1][j];
              sum[k][i] = sum[k][i+1];
          }
      }
     // dbg_ok;
      dp[a[i]][i][i]++;
      sum[a[i]][i]++;
  }
 // dbg_ok;
  
  int ans = 0 ;
  for(int i = 0 ; i <n-2 ; i++){
      for(int j=i+1 ; j<n-1 ; j++){
         if(a[i]!=a[j]){
         int k = 3-(a[i]+a[j]);
         ans+=sum[k][j+1];
         if(j+(j-i)<n){
         ans-=dp[k][j+1][j+(j-i)];
         }
         }
      }
  }
  cout<<ans;

}
 
 

Measured memory_bytes: 378624
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  bool f = true;
  if(a * b % 2 == 0) f = false;
  YesorNo(f);
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

const int N = 2005;
int n, k, q, a[N], ans = 1e9+5, t[N], b[N], c[N];

void cal(int mn){
    int l = 1, r = 1;
    b[0] = 0;
    while(l <= n){
        c[0] = 0;
        while(a[l] < mn && l <= n)  l++;
        r = l;
        while(a[r] >= mn && r <= n) r++;
        for(int i = l; i < r && i <= n; i++)
            c[++c[0]] = a[i];
        if(c[0] >= k){
            sort(c+1, c+c[0]+1);
            for(int i = 1; i <= c[0] - k + 1; i++)
                b[++b[0]] = c[i];
        }
        l = r;
    }
    sort(b+1, b+b[0]+1);
    if(b[0] >= q)   ans = min(ans, b[q] - b[1]);
}

int main(){
    scanf("%d%d%d", &n, &k, &q);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        t[i] = a[i];
    }
    sort(t+1, t+n+1);
    for(int i = 1; i <= n; i++)
        cal(t[i]);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t N = 1e5 + 5;
const size_t M = 13;
const int MOD = 1e9 + 7;

void iadd(int &dp, int val) {
    dp += val;
    if (dp >= MOD) dp -= MOD;
}

int dp[N][M], pw10[N];
char s[N];

int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    pw10[n] = 1;
    for (int i = n; i; --i) {
        pw10[i - 1] = pw10[i] * 10 % M;
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        int lb = 0, rb = 9;
        if (s[i] != '?') {
            lb = s[i] - '0';
            rb = s[i] - '0';
        }
        for (int j = 0; j < M; ++j) {
            if (dp[i - 1][j]) {
                for (int k = lb; k <= rb; ++k) {
                    iadd(dp[i][(j + k * pw10[i]) % M], dp[i - 1][j]);
                }
            }
        }
    }
    cout << dp[n][5];
    return 0;
}

Measured memory_bytes: 5760
#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<pair<int,int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
#define standardVar ll n,m,i,j,k,num,num1,num2,flag=0
#define nn <<"\n"
#define __ <<" "<<
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define ittr(x,v) for(auto x=v.begin();x!=v.end();x++)
#define itr(x,n) for(x=0;x<n;x++)
#define itrab(x,a,b) for(x=a;x<b;x++)
#define itpr(v) ittr(x,v)cout<<*x<<" "; cout nn
#define itppr(v) ittr(x,v)cout<<(*x).ff<<" "<<(*x).ss<<"  "; cout nn
#define size(x) (ll)x.size()
#define pi 3.14159265359
#define dTor(x) ((x)*pi)/180.0

typedef long long int ll;       //TYPEDEFS
typedef long double ld;
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef set<ll> sl;
typedef string str;
typedef pair<ll, ll> pl;
typedef vector< pl > vpl;
typedef map<pl,ll> mpl;
typedef set< pl > spl;
typedef vector<str> vst;
typedef vector<vl> vvl;

const ll M=1000000007;          //COMMON MODULO PRIMES
const ll N=998244353;

ll power(ll x, ll y, ll p){     //MODULAR EXPONENTIATION
    ll res=1;
    x=x%p;
    if(x==0)
        return 0;
    while(y>0){
        if(y&1)
            res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}
ll inv(ll x, ll m){             //FERMAT INVERSE
    return power(x,m-2,m);
}
struct comp{                    //COMPARISON ON PAIRS
    template<typename T>        
    bool operator()(const T &a, const T &b){
        if (a.ff==b.ff)
            return (a.ss<b.ss);
        else
            return (a.ff<b.ff);
    }
};
bool mod(const pair<ll,ll> &a, const pair<ll,ll> &b){   //COMPARATOR FOR PAIRS (SORTING)
    if(a.ff!=b.ff)
        return (a.ff>b.ff);
    else
        return (a.ss>b.ss);
}
vector<bool> pr(1000000+1,1);
void sieve(ll mn, ll mx){       //SIEVE OF ERATOSTHENES
    for(ll i=mn;i*i<=mx;i++)
        if(pr[i-mn]==1)
            for(ll j=i*i;j<=mx;j+=i)
                pr[j-mn]=0;
}
bool isValid(ll i, ll j, ll n, ll m){   //CHECKS FOR OVERFLOW
    if(i>=0&&i<n&&j>=0&&j<m){
        return true;
    }
    return false;
}

//MAIN FUNCTION STARTS HERE

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    standardVar;
    cin>>n;
    vl a(n+1);
    for(i=1;i<=n;i++){
        for(j=i;j<=n;j+=i){
            a[j]++;
        }
    }
    ll ans=0;
    for(i=1;i<=n;i++){
        ans+=i*a[i];
    }
    cout<<ans nn;
    return 0;
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {


			//テンプレート
			//// 整数の入力
			//int a = int.Parse(Console.ReadLine());
			//// スペース区切りの整数の入力
			//string[] input = Console.ReadLine().Split(' ');
			//int b = int.Parse(input[0]);
			//int c = int.Parse(input[1]);
			//// 文字列の入力
			//string s = Console.ReadLine();
			////出力
			//Console.WriteLine(a + b + c + " " + s);

			string[] input = Console.ReadLine().Split(' ');
			int N = int.Parse(input[0]);
			int A = int.Parse(input[1]);
			int B = int.Parse(input[2]);

			int cost_taxi = B;
			int cost_train = N * A;
			int cost_min;

			if (cost_train >= cost_taxi)
				cost_min = cost_taxi;
			else
				cost_min = cost_train;

			Console.WriteLine(cost_min);
			Console.ReadLine();

        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
int main(){
    int h, w;
    while(1){
       scanf("%d %d\n", &h, &w);
       if(h == 0 && w == 0){
           break;
       }
       for(int i = 1; i <= h; i++){
            for(int i = 1; i <= w; i++){
                printf("#");
            }
            printf("\n");
       }
       printf("\n");
    }
    return 0;
}


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

string s;
int len;
int main()
{
	ios :: sync_with_stdio(false);
	cin >> s;
	len = s.size();
	if(len & 1) 
	{
		cout << "No";
		return 0;
	}
	for (register int i = 0;i < len;i ++)
	{
		if(s[i] == 'p' && s[len - i - 1] != 'q'){
			cout << "No";
			return 0;
		}
		if(s[i] == 'q' && s[len - i - 1] != 'p'){
			cout << "No";
			return 0;
		}
		if(s[i] == 'd' && s[len - i - 1] != 'b'){
			cout << "No";
			return 0;
		}
		if(s[i] == 'b' && s[len - i - 1] != 'd'){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
} 

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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; }


int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep(i,N) cin >> h[i];

    vector<ll> dp(N, INF_LL);
    dp[0] = 0;

    rep(i,N)
    {
        REP(j, 1, K+1)
        {
            if( i - j < 0 )break;
            chmin( dp[i], dp[i-j] + abs(h[i] - h[i-j]) );
        }
    }
    //rep(i,dp.size()) cout << dp[i] << " ";
    //cout << endl;
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
#include<algorithm>
#include <iomanip> 
#include<vector>
#define fo(i,n) for(ll i=0;i<n;i++)
#define f(i,n) for(ll i=1;i<n;i++)
#define ff(i,k,n) for(ll i=k,i<n;i++)
#define ll long long
/*Elegizip, elegizip otken sol bir shaktar-ai
 Elendeter zamanymnyn otip bara zhatkanny-ai
Umytylmas-Umytylmas Kairan esil shaktar-ai
Zamanymnyn kolyn bulgap otip bara jatkany-ai
 kairan esil , kairan esil shaktar-ai
kolyn bulgap zamanymnyn otip bara jatkany-ai;*/
using namespace std;

int main()
{ios::sync_with_stdio(0);
ll n;
cin>>n;
ll a[n];
fo(i,n){
    a[i]=0;
}
fo(i,n-1){
    ll x;
    cin>>x;
    a[x-1]++;
}
fo(i,n){
    cout<<a[i]<<endl;
}


}





Measured memory_bytes: 5176
#include <iostream>

using namespace std;

int main() {
  int n;
  int a, b, c, d;
  bool start = false;
  while(cin >> n, n) {
    if(start) cout << endl;
    start = true;
    int ans[4] = {};
    cin >> a >> b >> c >> d;
    int mn = (int)10e9;
    for(int i=0; i<=a; i++)
      for(int j=0; j<=b; j++)
	for(int k=0; k<=c; k++)
	  for(int l=0; l<=d; l++) {
	    const int all = a*10+b*50+c*100+d*500;
	    int temp = i*10+j*50+k*100+l*500;
	    if(temp - n >= 0) {
	      int mom = temp - n;
	      int D = mom/500; mom -= D*500;
	      int C = mom/100; mom -= C*100;
	      int B = mom/50; mom -= B*50;
	      int A = mom/10;
	      int cand = A+B+C+D + a-i + b-j + c-k + d-l;
	      	      
	      if(cand < mn) {
		mn = cand;
		/*
		cout << "cand: " << cand << endl;
		cout << i << " " <<j << " " <<k<<" "<<l<<endl;
		*/
		ans[0] = i; ans[1] = j; ans[2] = k; ans[3] = l;
	      }
	    }
	  }
    if(ans[0]) cout << "10 " << ans[0] << endl;
    if(ans[1]) cout << "50 " << ans[1] << endl;
    if(ans[2]) cout << "100 " << ans[2] << endl;
    if(ans[3]) cout << "500 " << ans[3] << endl;
  }
  
  return 0;
}

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

const int N = 100;

int n, count[N];

bool solve() {
  int d = n - 1;
  while (!count[d]) {
    d--;
  }
  for (int i = 0; i <= d; ++i) {
    int x = std::max(i, d - i);
    if (!count[x]) {
      return false;
    }
    count[x]--;
  }
  for (int i = 1; i < d; ++i) {
    int x = std::max(i, d - i) + 1;
    if (x < n) {
      count[x] = 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (count[i]) {
      return false;
    }
  }
  return true;
}

int main() {
  while (scanf("%d", &n) == 1) {
    memset(count, 0, sizeof(count));
    for (int i = 0, a; i < n; ++i) {
      scanf("%d", &a);
      count[a]++;
    }
    puts(solve() ? "Possible" : "Impossible");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S;
    cin >> S;

    ll ans = 0, B = 0;
    rep(i, S.size()) {
        if (S[i] == 'B') {
            B++;
        }
        else {
            ans += B;
        }
    }

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

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

int main(){
    int s, w; cin >> s >> w;

    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3576
#include<stdio.h>

int main(){
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-h*3600-m*60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<long> vl;
typedef vector<vector<long> > vvl;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

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

    cout << N * (N - 1) / 2 << endl;
    return 0;
}


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

#define int long long

using namespace std;

int N;
string inp;
int C[4];

signed main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> inp;
        if (inp == "AC")
        {
            C[0]++;
        }
        else if (inp == "WA")
        {
            C[1]++;
        }
        else if (inp == "TLE")
        {
            C[2]++;
        }
        else
        {
            C[3]++;
        }
    }

    cout << "AC x " << C[0] << endl;
    cout << "WA x " << C[1] << endl;
    cout << "TLE x " << C[2] << endl;
    cout << "RE x " << C[3] << endl;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n,m;
  cin >> n >> m;
  vector<list<pair<int,int>>> e(n);
  int a,b;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    e[b-1].push_back({a-1,i});
    e[a-1].push_back({b-1,i});
  }
  int ans=0;
  for(int i=0;i<m;i++){
    vector<bool> arrived(n,false);
    queue<int> bfs;
    arrived[0]=true;
    bfs.push(0);
    while(!bfs.empty()){
      int now=bfs.front();
      bfs.pop();
      for(auto ne:e[now]){
        if(!arrived[ne.first]&&ne.second!=i){
          arrived[ne.first]=true;
          bfs.push(ne.first);
        }
      }
    }
    for(int i=0;i<n;i++){
      if(!arrived[i]){
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 













int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> vec[m];
    for(int i=0;i<m;i++){
         int k;
         cin>>k;
         vec[i].resize(k);
         for(int j=0;j<k;j++){cin>>vec[i][j];--vec[i][j];}
    }
    int ans=0;
    vector<int> p(m);
    for(int i=0;i<m;i++)cin>>p[i];
    for(int i=0;i<(1<<n);i++){
         bool ok=true;
         for(int j=0;j<m;j++){
              int ct=0;
              for(auto it:vec[j]){
                   if((i>>it)&1)ct++;
              }
              ct%=2;
              if(ct!=p[j])ok=false;
         }
         if(ok)ans++;
    } 
    cout<<ans;
}























Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

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

using namespace std;

int mat[625][626];

bool solve(int n){
	bool used[625]={};
	rep(j,n){
		int i;
		for(i=0;i<n;i++) if(!used[i] && mat[i][j]==1) break;
		if(i<n){
			used[i]=true;
			rep(k,n) if(i!=k && mat[k][j]==1) {
				for(int l=j;l<=n;l++) mat[k][l]=(mat[k][l]+mat[i][l])&1;
			}
		}
	}

	rep(i,n) if(!used[i] && mat[i][n]==1) return false;

	return true;
}

int main(){
	for(int m,n,d;scanf("%d%d%d",&n,&m,&d),m;){
		int a[25][25];
		rep(i,m) rep(j,n) scanf("%d",a[i]+j);

		memset(mat,0,sizeof mat);
		rep(i,m) rep(j,n) {
			mat[i*n+j][i*n+j]=1;
			rep(ii,m) rep(jj,n) if(abs(ii-i)+abs(jj-j)==d) {
				mat[ii*n+jj][i*n+j]=1;
			}
			mat[i*n+j][m*n]=a[i][j];
		}

		puts(solve(m*n)?"1":"0");
	}

	return 0;
}

Measured memory_bytes: 2268
#include<iostream>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;

int main(){
    int N; cin>>N;
    vector<tuple<string,int,int>> p(N);
    for(int i=0;i<N;i++){
        string s;
        int n;
        cin>>s>>n;
        p[i]=make_tuple(s,-n,i+1);
    }
    sort(p.begin(),p.end());
    for(int i=0;i<N;i++){
        cout<<get<2>(p[i])<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, N) for (int i = 0; i < (N); i++)
#define REP(i, a, N) for (int i = a; i < (N); i++)
#define rrep(i, N, k) for (int i = (N); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - 1e8;
const ll INFLL = numeric_limits<ll>::max() - 1e17;

int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    cin >> a;
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, -INFLL));
    function<ll(int, int)> calc = [&](int l, int r) {
        if (dp[l][r] != -INFLL) return dp[l][r];
        if (l == r) return dp[l][r] = a[l];
        return dp[l][r] = max(a[l] - calc(l + 1, r), a[r] - calc(l, r - 1));
    };
    cout << calc(0, N - 1) << endl;
}

Measured memory_bytes: 71552
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> da(n);
	for (int i = 0;i < n;i++) {
		cin >> da[i].first >> da[i].second;
	}
	sort(da.begin(), da.end());
	long long ans = 0;
	priority_queue<int> q;
	int flag = 0;
	for (int i = 1;i < m + 1;i++) {
		while (flag<n && da[flag].first == i) {
			q.push(da[flag].second);
			flag++;
		}
		if (!q.empty()) {
			ans =(long long ) ans+ q.top();
			q.pop();
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1660
#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC push_options
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 998244353ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	doin();
	ll n, m, c, ans, t, z;
	ans = 0;
	cin >> n >> m >> c;
	vi b;
	getv(b, m);
	for(int i = 0; i < n; i++) {
		t = c;
		for(int j = 0; j < m; j++) {
			cin >> z;
			t += b[j]*z;
		}
		if(t > 0)
			ans++;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;
ll dp[51][51][2501] = {};
ll x[51];
int main(){
  ll N,A;
  cin >> N >> A;
  REPS(i,N) cin >> x[i];
  REP(i,N+1) dp[i][0][0] = 1;
  REPS(i,N){
    REPS(j,N){
      REP(k,2501){
        dp[i][j][k] = dp[i-1][j][k];
        if(k >= x[i]) dp[i][j][k] += dp[i-1][j-1][k-x[i]];
      }
    }
  }
  ll ans = 0;
  REPS(i,N) ans += dp[N][i][A*i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 50048
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#define INF 1e9+10
const int mod = 1e9+7;
using namespace std;
map<int,int>degree;
set<int> pfactor;
int n,x;
long long product,ans=1;
void getfa(int x){
    for(int i=2;i<=x;i++){
        while(x%i==0){
            pfactor.insert(i);
            ++degree[i];
            x/=i;
        }
    }
    return;
}
int main(){
    scanf("%d",&n);
    for(int i=2;i<=n;i++)
        getfa(i);
    for(auto k:pfactor)
        ans=ans*(1+degree[k])%mod;
    printf("%lld",ans);
}

Measured memory_bytes: 3260
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    # key[i]:10進数でiを開けれる鍵の値段
    key = [inf]*(1<<n)
    for _ in range(m):
        a,b = map(int, input().split())
        c = list(map(int, input().split()))
        binary = 0
        for i in c:
            binary += 2**(i-1)
        key[binary] = min(key[binary], a)

    # dp[i]:10進数で宝iを開けてる時の最小値段
    dp = [inf]*(1<<n)
    dp[0] = 0
    for i in range(1<<n):
        if key[i] == inf:
            continue
        for s in range(1<<n):
            if (i|s) == s:
                continue
            dp[i|s] = min(dp[i|s], dp[s]+key[i])
    if dp[-1] == inf:
        print(-1)
    else:
        print(dp[-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 43356
/*{{{*/
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

typedef long long ll;
typedef std::pair<int, int> pii;

std::string Name = __FILE__;
std::string iput = Name.substr(0, Name.length() - 4) + ".in";
std::string oput = Name.substr(0, Name.length() - 4) + ".out";

template <class T> inline bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template <class T> inline bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }

template <class T> inline T &read(T &x)
{
    static int f;
    static char c; 
    for (f = 1; !isdigit(c = getchar()); ) {
        if (c == '-')
            f = -1;
    }
    for (x = 0; isdigit(c); c = getchar()) {
        x = x * 10 + c - 48;
    }
    return x *= f;
}
 
template <class T> inline void write(T x, const char p = '\n')
{
    static int top;
    static int s[30];
    if (x < 0) {
        x = -x;
        putchar('-');
    }
    do s[++ top] = x % 10 + 48;
    while (x /= 10);
    while (top)
        putchar(s[top --]);
    putchar(p);
}
/*}}}*/
 
const int maxn = 2e5 + 5;
 
int n, m;
int a[maxn];
int max, pos;

void exec()
{
    read(n);
    read(m);
    for (int i = 1; i <= n; ++ i) {
        read(a[i]);
        if (i != 1 && chkmax(max, a[i] + a[i - 1])) pos = i;
    }
    if (max >= m) {
        puts("Possible");
        for (int i = 1; i < n; ++ i) if (i != pos - 1) write(i); else break;
        for (int i = n - 1; i; -- i) if (i != pos - 1) write(i); else break;
        write(pos - 1);
    } else puts("Impossible");
}

/*{{{*/
int main() 
{
    if (fopen(iput.c_str(), "r") != NULL) {
        freopen(iput.c_str(), "r", stdin);
        freopen(oput.c_str(), "w", stdout);
    }

    exec();

    fclose(stdin);
    fclose(stdout);

    return 0;
}
/*}}}*/



Measured memory_bytes: 1152
//According to all known laws of aviation, there is no way that a bee should be able to fly.
//Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway.
//Because bees don't care what humans think is impossible.
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
bigint arr[300011] ;
int main(){
    int N ; cin >> N ;
    cout << ( N / 1001 + 1 ) * 1000 - N << endl ;
    return 0 ;
}


Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vector<int> data(n);
    for (int i = 0; i < n; i++)
    {   
        cin >> data[i];
    }   
    int res = 0;
    if (data[0] == 1)
    {   
        swap(data[0], data[1]);
        ++res;
    }   
    if (data[n - 1] == n)
    {   
        swap(data[n - 1], data[n - 2]);
        ++res;
    }   
    for (int i = 1; i < n - 1; i++)
    {   
        if (data[i] == i + 1)
        {
            swap(data[i], data[i + 1]);
            ++res;
        }
    }   
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 640
S = input()
c = ["dream","dreamer","erase","eraser"]

S = S[::-1]
c = [cc[::-1] for cc in c]

i=0
while i < len(c):
    if S.startswith(c[i]):
        S = S[len(c[i]):]
        i = 0
        continue
    i = -~i

print("NYOE S"[S==""::2])


Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>

void check(char *s) {
  int i, len, maxlen;
  while (*s != '\0') {
    if (*s == 'A') {
      len = 0;
      break;
    }
    s++;
  }
  while (*s != '\0') {
    len++;
    s++;
    if (*s == 'Z') {
      maxlen = len;
    }
  }
  printf("%d\n", maxlen + 1);
}

int main(void) {
  char *s;
  s = (char *)malloc(sizeof(char) * 200000);
  scanf("%s", s);
  check(s);
  return 0;
}

Measured memory_bytes: 384
#include<string.h>
#include<stdio.h>
int main(void){
  char a[10],b[10],c[10];
  scanf("%s %s %s",a,b,c);
  if((a[strlen(a)-1]==b[0]) && (b[strlen(b)-1]==c[0])) printf("YES\n");
  else printf("NO\n");
  return 0;
}

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

using namespace std;

long long powMod(long long x, long long k, long long m) {
    if (k == 0) return 1;
    if (k % 2 == 0) return (powMod(x * x % m, k / 2, m) + m) % m;
    else return (x * powMod(x, k - 1, m) + m) % m;
}

long long MOD = 1e9 + 7;

int main() {
    long long m, n;
    cin >> m >> n;

    cout << powMod(m, n, MOD) << endl;
    return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        int[] weights = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

        while (scanner.hasNextInt()) {
            int weight = scanner.nextInt();
            boolean space = false;
            for (int i = 0; weight > 0; i++) {
                if ((weight & 0x1) == 0x1) {
                    if (space) {
                        System.out.print(" ");
                    }
                    System.out.print(weights[i]);
                    space = true;
                }
                weight >>= 1;
            }
            System.out.println();
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
n,m,l=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]
B=[list(map(int,input().split())) for i in range(m)]
C=[[0]*l for i in range(n)]

for x in range(n):
    for y in range(l):
        for z in range(m):
            C[x][y] += A[x][z]*B[z][y]

for row in range(n):
    print("%d"%(C[row][0]),end="")
    for col in range(1,l):
        print(" %d"%(C[row][col]),end="")
    print()



Measured memory_bytes: 7052
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  ll res = 0;
  vector<ll> num;
  for(int i = 2;i <= sqrt(n);i++){
    if(n % i == 0)num.push_back(i)/*,cout << num[num.size() - 1] << endl*/;
    if(i >= sqrt(n))break;
  }
  ll copy = 0;
  copy = n;
  for(int i = 0;i < num.size();i++){
    copy = n;
    while(copy % num[i] == 0)copy /= num[i];
    //cout << "i" << i << " " << copy << endl;
    if(copy % num[i] == 1)res++/*,cout << num[i] << endl*/;
  }
  res++;//k=nの時の分
  //cout << res << endl;
  ll kosuu = 0;
  kosuu = 1;
  copy = n - 1;
  for(ll i = 2;i <= sqrt(copy);i++){
    if(copy % i == 0){
      kosuu++;
      if(ll(pow(i,2)) != copy)kosuu++/*,cout << "AAA" << endl*/;
      //cout << "!" << i << endl;
      //cout << (ll)pow(i,2) << " " << copy << endl;
    }
    //if(i * i == n - 1)kosuu--;
    if(i >= sqrt(copy))break;
  }
  //cout << kosuu << endl;
  //cout << kosuu << endl;
  if(n - 1 >= 2)res += kosuu;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
#define dmp make_pair
#define fi first
#define se second
const int inf = 1e9;
const int INF = 1e18;
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = 1;i <= n;i++)

int q[200002][3], ran[100002];
pair<int,int> p[100002];
P find(int x, int y){
	if(p[x].fi == x)return P(x, y);
	else {
		p[x] = find(p[x].fi, p[x].se);
		return P(p[x].fi, p[x].se+y);
	}
}

bool unite(int xx, int yy, int d){
	P x = find(xx, 0);
	P y = find(yy, 0);
	if(x.fi == y.fi){
		if(x.se+d == y.se)return 0;
		else return 1;
	}
	if(ran[x.fi] < ran[y.fi]){
		p[x.fi] = P(y.fi, y.se-d-x.se);
	}else{
		p[y.fi] = P(x.fi, x.se+d-y.se);
		if(ran[x.fi] == ran[y.fi])ran[x.fi]++;
	}
	return 0;
}

bool same(int x, int y){
	return find(x, 0).fi == find(y, 0).fi;
}

signed main(){
	int n, m;
	scanf("%lld%lld", &n, &m);
	rep(i,m)rep(j,3)scanf("%lld", &q[i][j]);
	rep(i,n){
		p[i].fi = i;
		ran[i] = 0;
	}
	
	for(int i = 0;i < m;i++){
		int l = q[i][0]-1, r = q[i][1]-1, d = q[i][2];
		if(unite(l, r, d)){
			printf("No\n");
			return 0;
		}
	}
	
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s=="SUN"){
        cout << "7" << endl;
    }
    if(s=="MON"){
        cout << "6" << endl;
    }
    if(s=="TUE"){
        cout << "5" << endl;
    }
    if(s=="WED"){
        cout << "4" << endl;
    }
    if(s=="THU"){
        cout << "3" << endl;
    }
    if(s=="FRI"){
        cout << "2" << endl;
    }
    if(s=="SAT"){
        cout << "1" << endl;
    }
}

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

/*
   AtCoder contest
   coder : yoichidon
 */
public class Main {

    public  static long[] reverse(long[] array){
        int N = array.length;
        long[] ans = new long[N];
        for(int n=0; n<N; n++) ans[n]=array[N-n-1];
        return ans;
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int N = S.length();

        int[] redMax = new int[N];
        int[] blueMax = new int[N];
        for(int n=0; n<N; n++){
            int b = S.charAt(n)-'0';
            redMax[n] = (n==0) ? 2-b : 2-b+redMax[n-1];
            blueMax[n] = (n==0) ? b : b+blueMax[n-1];
        }

        
        long[][] dp = new long[redMax[N-1]+1][blueMax[N-1]+1];

        for(int r=0; r<=redMax[N-1]; r++) for(int b=0; b<=blueMax[N-1]; b++){
            int turn = r+b;
            if(r==0  && b==0) dp[r][b]=1;
            else if(turn<=N && (redMax[turn-1]<r || blueMax[turn-1]<b)) dp[r][b]=0;
            else if(r==0) dp[r][b]=dp[r][b-1];
            else if(b==0) dp[r][b]=dp[r-1][b];
            else dp[r][b] = (dp[r][b-1]+dp[r-1][b])%998244353;

        }

        System.out.println(dp[redMax[N-1]][blueMax[N-1]]);



    }
}


Measured memory_bytes: 80980
N = int(input())

A = [list(map(int, input().split())) for i in range(2)]

def dfs(i, j, candy):
    if(i > 1 or j >= N):
        return 0
    if(i == 1 and j == N - 1):
        return candy + A[1][N - 1]
    candy += A[i][j]
    return max(dfs(i + 1, j, candy), dfs(i, j + 1, candy))

print(dfs(0, 0, 0))


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

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int,int> Paint;

#define anyfill(n,s) setw(n) << setfill(s)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define pb push_back
#define MAX 1000000000
#define MOD 1000000007

int main(){
  int r,g,b,n;cin>>r>>g>>b>>n;
  int k = 0;
  for(int i = 0; n/r >= i; i++){
    for(int j = 0; n/g >= j; j++){
      if((n-(r*i+g*j))%b == 0 && n-(r*i+g*j)>=0 ){

        k++;
      }
    }
  }
  cout << k<< endl;
}

Measured memory_bytes: 256
n=int(input())
lst=[]
for i in range(n):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
C=[]
for i in range(n):
    C.append([float('inf')]*3)
C[0][0]=lst[0][0]
C[0][1]=lst[0][1]
C[0][2]=lst[0][2]
D=[0,1,2]
for i in range(n-1):
  for j in [0,1,2]:
    del D[j]
    C[i+1][j]=max(C[i][D[0]]+lst[i+1][j],C[i][D[1]]+lst[i+1][j])
    D=[0,1,2]
print(max(C[n-1]))
    
  
  


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

typedef long long int ll;

#define endl '\n'

ll n,m;
ll dp[2005][2005];
ll mod = (1e9)+7;
int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);


    cin>>n>>m;

    ll arr[n+1];
    ll brr[m+1];

    for(ll i=1;i<=n;i++)cin>>arr[i];

    for(ll i=1;i<=m;i++)cin>>brr[i];

    memset(dp,0,sizeof(dp));
    /*for(ll i=0;i<=n;i++){
        dp[i][0]=1;
    }
    for(ll j=0;j<=m;j++){
        dp[0][j]=1;
    }*/
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=m;j++)
        {
            if(arr[i]==brr[j])
            {
                dp[i][j] = (1+dp[i][j-1]+dp[i-1][j]+mod)%mod;
            }
            else{
                dp[i][j] = (-dp[i-1][j-1]+dp[i][j-1]+dp[i-1][j]+mod)%mod;
            }
        }
    }

    cout<<(dp[n][m]+1)%mod<<endl;



}


Measured memory_bytes: 31872