akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
int n, m, S;
ll dp[100][10000], C[N], D[N];
struct E
{
	int v, a, b;
};
vector<E>G[N];
struct X
{
	ll d;
	int u, c;
	bool operator<(const X& b)const {
		return d > b.d;
	}
};
void bfs(int s) {
	priority_queue<X>q;
	for (int i = 1; i <= n; i++)for (int j = 0; j < 10000; j++)dp[i][j] = inf;
	q.push(X{ 0,s,min(S,6000) });
	dp[s][min(S, 6000)] = 0ll;
	while (!q.empty()) {
		X t = q.top(); q.pop();
		int u = t.u, c = t.c;
		ll d = t.d;
		for (E e : G[u]) {
			if (e.a > c)continue;
			if (dp[e.v][c - e.a] > dp[u][c] + e.b) {
				dp[e.v][c - e.a] = dp[u][c] + e.b;
				q.push(X{ dp[e.v][c - e.a],e.v,c - e.a });
			}
		}
		int nc = min(6000ll, c + C[u]);
		if (dp[u][nc] > dp[u][c] + D[u]) {
			dp[u][nc] = dp[u][c] + D[u];
			q.push(X{ dp[u][nc],u,nc });
		}
	}
}
int main() {
	scanf("%d%d%d", &n, &m, &S);
	for (int i = 0; i < m; i++) {
		int u, v, a, b;
		scanf("%d%d%d%d", &u, &v, &a, &b);
		G[u].push_back(E{ v,a,b });
		G[v].push_back(E{ u,a,b });
	}
	for (int i = 1; i <= n; i++)scanf("%lld%lld", &C[i], &D[i]);
	bfs(1);
	for (int i = 2; i <= n; i++) {
		ll ans = inf;
		for (int j = 0; j <= 6000; j++)
			ans = min(ans, dp[i][j]);
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 16044
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

 int n;string s;
int a[999],b[999];
int ans=0;
void solve()
{
   cin>>n>>s;
    REP(i,n)a[s[i]]++;
    int ans=0;
    REP(i,n)
    {
        a[s[i]]--;
        b[s[i]]++;
        int sum=0;
        rep(j,'a','z'+1)if(a[j]&&b[j])sum++;
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int H,W;cin>>H>>W;
    vector<vector<int>> S(H, vector<int>(W));
    for (int i = 0; i < H; i++)
    {
        string s;cin>>s;
        for (int j = 0;j < W;j++)
        {
            S[i][j] = s[j] == '.' ? 1 : 0;
        }
        
    }
    vector<vector<int>> dp(H, vector<int>(W,0));
    for(int i = 0;i < H;i++){
        for (int j = 0; j < W; j++)
        {
            if(i == 0 && j== 0){
                dp[i][j] = S[i][j] == 0 ? 1 : 0;
                continue;
            }
            if(S[i][j] == 1){
                int a = i > 0 ? dp[i-1][j] : 1000000;
                int b = j > 0 ? dp[i][j-1] : 1000000;
                dp[i][j] = min(a,b);
                continue;
            }
            
            int res = 10000000;
            if(i > 0){
                int add = S[i-1][j] == 1 ? 1 : 0;
                res = min(res, dp[i-1][j] + add);
            }
            
            if(j > 0){
                int add = S[i][j-1] == 1 ? 1 : 0;
                res = min(res, dp[i][j-1] + add);
            }
            dp[i][j] = res;
        }
        
    }
    // for (int i = 0; i < H; i++)
    // {
    //     for (int j = 0; j < W; j++)
    //     {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
        
    // }
    
    cout<<dp[H-1][W-1]<<endl;
}

Measured memory_bytes: 384
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
	public static void main (String[] args) throws java.lang.Exception{
           BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
           int N = Integer.parseInt(br.readLine());
           int f=0,s=0,e=0;
           int a1,a2,a3;
           String[] x;
           for(int i=0;i<N;++i){
               x = br.readLine().split("\\s");
               a1 = Integer.parseInt(x[0]);
               a2 = Integer.parseInt(x[1]);
               a3 = Integer.parseInt(x[2]);
               
               int n1,n2,n3;
               
                n1 = a1 + Math.max(s,e);
                n2 = a2 + Math.max(f,e);
                n3 = a3 + Math.max(s,f);
                
                f = n1;
                s = n2;
                e = n3;
               
               
               
               
               
           }
           
           System.out.println(Math.max(f,Math.max(s,e)));
	}
}

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

int main() {
  int h1,m1,h2,m2,k;
  cin >>h1>>m1>>h2>>m2>>k;
  int hun=m2-m1;
  int jikan=h2-h1;
  if(hun<0){
    jikan--;
    hun+=60;
  }
  int kotae=jikan*60+hun-k;
  cout<<kotae<<endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  int now, seeable=0, highest=0;
  for(int i=0; i<N; i++){
    cin >> now;
    if(highest <= now){
      seeable++;
      highest=now;
    }
  }
  
  cout << seeable;
}

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

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

    int x = s / 100;
    int y = s % 100;

    string ans;
    if(x >= 1 && x <= 12 && y >= 1 && y <= 12)
        ans = "AMBIGUOUS";
    else if(y >= 1 && y <= 12)
        ans = "YYMM";
    else if(x >= 1 && x <= 12)
        ans = "MMYY";
    else
        ans = "NA";
    
    cout << ans << endl;
}


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

struct Data {
  int A, v;
  Data(int A, int v) : A(A), v(v){}
  bool operator < (const Data &d) const {
    return A < d.A;
  }
};

int main() {
  int N;
  cin >> N;
  vector<Data> d;
  int A;
  for (int i = 0; i < N; i++) {
    cin >> A;
    d.push_back(Data(A, i + 1));
  }
  sort(d.begin(), d.end());
  for (int i = 0; i < N; i++) {
    if (i == N - 1) cout << d[i].v << "\n";
    else cout << d[i].v << " ";
  }
  return 0;
}

Measured memory_bytes: 1780
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
int a;
int b;
int k;
void solve(){
    int count=0;
    for(int i =min(a,b);i>0;i--){
        if(a%i==0&&b%i==0){
            count++;
            if(count==k) {
                cout<<i<<'\n';
                break;
            }
        }
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a>>b>>k;
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  dump(-10 % 3);
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, 0, N) { cin >> A[i]; }

  int sum = accumulate(all(A), 0ll);

  if (sum % ((N + 1) * N / 2) == 0) {
    int k = sum / ((N + 1) * N / 2);
    vector<int> d(N);
    rep(i, 0, N) d[i] = A[(i + 1) % N] - A[i] - k;
    bool f = true;
    rep(i, 0, N) {
      dump(d[i], d[i] % N);

      if (d[i] % N != 0 or d[i] > 0)
        f = false;
    }

    if (f)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  } else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 1792
using System;
public class Hello{
    public static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        bool flag = true;
        for(int x = 0;x < input.Length - 1;x++){
            if(input[x].Substring(input[x].Length - 1,1) != input[x + 1].Substring(0,1)){
                flag = false;
                break;
            }
        }
        if(flag == true){
            Console.WriteLine("YES");
        }else{
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 11092
// B - OddString

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	for (int i=0; i<s.size(); i+=2) {
		ans.push_back(s[i]);
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//-------------------------------------------------------------------------------

#define MAX 10000

int main(void) {
  cin >> n >> m;
  vector<pll> p;
  ll x, y, k, f, g;
  ll x1, x2, y1, y2;
  FOR(i, 0, n) {
	cin >> x >> y;
	p.push_back(make_pair(x, y));
  }

  sort(ALL(p));
  ans = INF;

  FOR(i, 0, n - m + 1) {
	FOR(j, i, n) {
	  FOR(k, i, n) {
		FOR(f, i, n) {
		  cnt = 0;
		  x1 = max(p[i].first, p[j].first);
		  x2 = min(p[i].first, p[j].first);
		  y1 = max(p[k].second, p[f].second);
		  y2 = min(p[k].second, p[f].second);
		  FOR(g, i, n) {
			temp = p[g].first;
			if (temp <= x1 && temp >= x2) {
			  temp = p[g].second;
			  if (temp <= y1 && temp >= y2) {
				cnt++;
			  }
			}
		  }
		  if (cnt < m) continue;
		  x = llabs(p[i].first - p[j].first);
		  y = llabs(p[k].second - p[f].second);
		  ans = min(ans, x*y);
		}
	  }
	}
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
/*
* Filename:    aoj0118.cpp
* Desciption:  DFS
* Created:     2016-03-02
* Author:      JIngwei Xu [mail:xu_jingwei@outlook.com]
*
*/
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cstring>
#define INT_MAX 2<<30
using namespace std;
//typedef long long ll;
int n,m,ans;
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
char maze[105][105];
void dfs(int x,int y,char s){
	
	int tx,ty;
	maze[x][y]=0;
	for (int i = 0; i < 4; i += 1)
	{
		tx=x+dx[i];ty=y+dy[i];
		if(tx<0||ty<0||tx>=n||ty>=m)continue;
		if(maze[tx][ty]==s)dfs(tx,ty,s);
	}
}
int main()
{
	while (scanf("%d%d",&n,&m)&&n&&m)
	{
		for (int i = 0; i < n; i += 1)
		{
			scanf("%s",maze[i]);
		}
		ans=0;
		for (int i = 0; i < n; i += 1)
		{
			for (int j = 0; j < m; j += 1)
			{
				if(maze[i][j]!=0){
					dfs(i,j,maze[i][j]);
					ans++;
				}
			}
		}
		printf("%d\n",ans);
		
	}
	return 0;
}

Measured memory_bytes: 1668
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	int N, i;
	cin >> N >> i;

	cout << N - i + 1;

	return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
    int w, a, b;
    cin >> w >> a >> b;
    if(abs(a - b) <= w){
        cout << 0 << endl;
    }else{
        cout << min(abs(a + w - b), abs(b + w - a)) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef long long unsigned int llong;


int main(){
    int n,t;
    cin >> n >> t;
    cout << max(n-t,0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
	int temp,n,k,t[100000],m,s[100000];
	cin>>n>>k;
	m=n;
	for(int i=0;i<n;i++)
	{
		cin>>t[i];
	}
	for(int i=0;i<n-1;i++)
	{
		s[i]=t[i+1]-t[i]-1;
	}

	sort( s ,s + n - 1 ) ;

	for(int i=0;i<n-k;i++)
	{
		m+=s[i];
	}
	cout<<m<<endl;	
	return 0;
}


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

int main() {
  char c;
  cin>>c;

  if(c=='a'){
      cout<<"vowel"<<endl;
  }
  else if(c=='i'){
      cout<<"vowel"<<endl;
  }
  else if(c=='u'){
      cout<<"vowel"<<endl;
  }
  else if(c=='e'){
      cout<<"vowel"<<endl;
  }
  else if(c=='o'){
      cout<<"vowel"<<endl;
  }
  else{
      cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
int p;
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%p;
    int memo=modpow(a,b/2);
    return memo*memo%p;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=p;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],p-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%p*invkaijo[b]%p;
}
int inv(int x){
    x=modpow(x,p-2);
    return x;
}
int a[3010],ans[3010];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>p;
    init_fact(p);
    rep(i,p)cin>>a[i];
    rep(i,p){
        if(a[i]==1){
            ans[0]++;
            rep(j,p){;
                if(j%2==0)ans[p-1-j]-=comb(p-1,j)*modpow(i,j)%p;
                else ans[p-1-j]+=comb(p-1,j)*modpow(i,j)%p;
                ans[p-1-j]+=p;
                ans[p-1-j]%=p;
            }
        }
    }
    rep(i,p)cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3704
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝

*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long  t,r=1,r1=0,r2=0,k=0,a,b,c=0,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    vector<tuple<string,int,
           int>>mp;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n>>m;
    (n<m)?cout<<"0":cout<<"10"<<endl;

}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    const ll mod=(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;}
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll man=(ll)1e5+5;
/*........................................................................................................................*/


signed main()
{
    fast;
    ll h,a;
    cin>>h>>a;
    cout<<(h+a-1)/a<<endl;
}

Measured memory_bytes: 3604
from collections import deque
def use_path(n,start,es):
    q = deque()
    chk = [False] * n
    q.append(start)
    chk[start] = True
    used = {start}
    while len(q) > 0:
        node = q.popleft()
        for nex in es[node]:
            if not chk[nex]:
                chk[nex] = True
                q.append(nex)
                used.add(nex)
    return used
  
def belman(s,g,n,es):
    d = [10**10] * n
    d[s] = 0
    fin = False
    cnt = 0
    while True:
      update = False
      for p,q,r in es:
        if d[p] != 10**10 and d[q] > d[p] + r:
          d[q] = d[p] + r
          update = True
      cnt += 1
      if not update:
        fin = True
        break
      if cnt > n+1:
          break      
    if fin:
        return max(0,-d[g])
    else:
        return -1   
  
n,m,p = map(int, input().split())

l = [[] for i in range(n)]
r = [[] for i in range(n)]
edges = []

for i in range(m):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    l[a].append(b)
    r[b].append(a)
    edges.append((a,b,-c+p))
    
use_nodes = use_path(n,0,l) & use_path(n,n-1,r)
es = [(a,b,c) for a,b,c in edges if a in use_nodes and b in use_nodes]
print(belman(0,n-1,n,es))


Measured memory_bytes: 11128
import sys
def input(): return sys.stdin.readline().strip()


def main():
    D = int(input())
    C = [0] + list(map(int, input().split()))
    S = [[0] * 27]
    for _ in range(D):
        S.append([0] + list(map(int, input().split())))
    T = [0]

    satisfactory = 0
    last = [0] * 27
    for d in range(1, D + 1):
        cand = (-1, -10**18) # (type, tmp)
        # 貪欲で最適解を求める
        for type in range(1, 27):
            tmp = S[d][type]
            for i in range(1, 27):
                if i == type: continue
                tmp -= C[i] * (d - last[i])
            if tmp > cand[1]:
                cand = (type, tmp)

        # 最適だったもので更新
        last[cand[0]] = d
        satisfactory += cand[1]
        T.append(cand[0])

    for i in range(1, D + 1):
        print(T[i])

if __name__ == "__main__":
    main()


Measured memory_bytes: 68568
memo = [[0] * 10 for i in range(10)]

def kazu(start_num,end_num):
    global memo
    if memo[start_num][end_num] > 0:
        #print('memo',start_num,end_num)
        return memo[start_num][end_num]
    else:
        ans = 0
        #1桁
        if start_num == end_num:
            if start_num <= n:
                #print(start_num)
                ans += 1
        #2桁
        if start_num * 10 + end_num <= n:
            #print(start_num * 10 + end_num)
            ans += 1
        #3桁
        for i in range(10):
            if start_num * 100 + i * 10 + end_num <= n:
                #print(start_num * 100 + end_num)
                ans += 1
            else:
                break
        #4桁
        for i in range(100):
            if start_num * 1000 + i * 10 + end_num <= n:
                #print(start_num * 1000 + end_num)
                ans += 1
            else:
                break
        #5桁
        for i in range(1000):
            if start_num * 10000 + i * 10 + end_num <= n:
                #print(start_num * 10000 + end_num)
                ans += 1
            else:
                break
        #6桁
        for i in range(10000):
            if start_num * 100000 + i * 10 + end_num <= n:
                #print(start_num * 10000 + end_num)
                ans += 1
            else:
                break
        memo[start_num][end_num] = ans
        #print(start_num,end_num,'---',ans)
        return ans

n = int(input())
str_n = str(n)
kotae = 0
#print(memo)
for a in range(1,n+1):
    if a%10!=0:
        str_a = str(a)
        #print('-----',a,'-----',int(str_a[-1]),int(str_a[0]))
        kotae += kazu(int(str_a[-1]),int(str_a[0]))
        #print(memo)
print(kotae)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

map<pair<string, int>, int> mp;

int main()
{
    int a, p, ans = 0;
    cin>>a>>p;
    cout<<(a*3+p) / 2<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Pathological Paths - Wrong Answer
 */
public class Main {

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

		Main main = new Main();

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int N, M;
			N = parseInt(line.substring(0, line.indexOf(' ')));
			M = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((N | M) == 0) break;

			Dir root = main.new Dir("/");

			for (int i = 0; i < N; i++) {
				root.addFile(br.readLine());
			}
			for (int i = 0; i < M; i++) {
				String q1 = br.readLine();
				String q2 = br.readLine();
				if (root.abs(q1).equals("") || root.abs(q2).equals("")) {
					System.out.println("not found");
				} else if (root.abs(q1).equals(root.abs(q2))) {
					System.out.println("yes");
				} else {
					System.out.println("no");
				}
			}

		} //end while
	} //end main

	class Dir {

		Dir parent;
		String name;
		Map<String, Dir> subdirs;
		Set<String> files;

		Dir(String name) {
			this.name = name;
			subdirs = new HashMap<>();
			files = new HashSet<>();
		}

		void addFile(String path) {
			String[] parts = path.split("/");
			Dir dir = this, parent = this;
			for (int i = 1; i < parts.length - 1; i++) {
				if (!dir.subdirs.containsKey(parts[i])) {
					dir.subdirs.put(parts[i], new Dir(parts[i]));
				}
				dir = dir.subdirs.get(parts[i]);
				dir.parent = parent;
				parent = dir;
			}
			dir.files.add(parts[parts.length - 1]);
		}

		String abs(String path) {

			Deque<String> abs = new ArrayDeque<>();
			abs.offer("/");

			String[] parts = path.split("/");
			Dir dir = this, parent = this;
			boolean isDir = true;

			for (int i = 1; i < parts.length; i++) {
				switch (parts[i]) {
					case "..":
						dir = dir.parent;
						if (dir != null) {
							abs.pollLast();
						} else {
							return "";
						}
						break;
					case ".":
						break;
					default:
						if (dir.subdirs.containsKey(parts[i])) {
							dir = dir.subdirs.get(parts[i]);
							abs.offer(parts[i] + "/");
						} else if (i == parts.length - 1
								&& path.charAt(path.length() - 1) != '/'
								&& !parts[parts.length - 1].equals(".")
								&& !parts[parts.length - 1].equals("..")) {
							if (dir.files.contains(parts[i])) {
								abs.offer(parts[i]);
								isDir = false;
							} else {
								return "";
							}
						} else {
							return "";
						}
				}
			}
			if (isDir) {
				if (dir.files.contains("index.html")) {
					abs.offer("index.html");
				} else {
					return "";
				}
			}
			//
			StringBuilder sb = new StringBuilder();
			for (String s : abs) sb.append(s);
			return sb.toString();
		}
	}
}

Measured memory_bytes: 24636
#include<bits/stdc++.h>
typedef long long ll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7;
using namespace std;
ll t;
ll arr[200005];
int main()
{
    ll a,b,c,d,e,f,i,j;
    cin>>a>>b;
    for(i=1;i<=a;i++)
    {
        cin>>arr[i];
    }
    c=N;
    sort(arr+1,arr+a+1);
    for(i=b;i<=a;i++)
    {
        c=min(c,(arr[i]-arr[i-b+1]));
    }
    cout<<c<<endl;


return 0;

}


Measured memory_bytes: 1024
dim = [0] * 4
for i in range(3):
  a, b = map(int, input().split())
  dim[a-1] += 1
  dim[b-1] += 1

num_odd = sum([d % 2 for d in dim])
if num_odd in [0, 2]:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
import sys
import math
# input処理を高速化する
input = sys.stdin.readline

BingoCard = []

for i in range(3):
    a =  list(map(int,input().split()))
    BingoCard.append(a)

N = int(input())

for i in range(N):
    b_i = int(input())

    for j in range(3):
        for k in range(3):
            if BingoCard[j][k] == b_i:
                BingoCard[j][k] =0

#ビンゴかどうか判定
if BingoCard[0] ==[0,0,0]:
    print('Yes')
elif BingoCard[1] ==[0,0,0]:
    print('Yes')
elif BingoCard[2] ==[0,0,0]:
    print('Yes')
elif [n[0] for n in BingoCard] ==[0,0,0]:
    print('Yes')
elif [n[1] for n in BingoCard] ==[0,0,0]:
    print('Yes')
elif [n[2] for n in BingoCard] ==[0,0,0]:
    print('Yes')
elif [BingoCard[n][n] for n in range(3)] ==[0,0,0]:
    print('Yes')
elif [BingoCard[n][2-n] for n in range(3) ] ==[0,0,0]:
    print('Yes')
else:
    print('No')

# print(*BingoCard,sep="\n")

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    a,b,c,d=map(int,list(input()))
    for i in range(2):
        ans=str(a)
        if i: ans+='-'
        else: ans+='+'
        ans+=str(b)
        for j in range(2):
            if j: 
                ans=ans[:-2]
                ans+='-'
            else: ans+='+'
            ans+=str(c)
            for k in range(2):
                if k: ans+='-'
                else: ans+='+'
                ans+=str(d)
                if eval(ans)==7:
                    print(ans+'=7')
                    exit()
                else: ans=ans[:-2]


if __name__ == "__main__":
    main()

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

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            var result = 0;
            var max = s.Distinct().Count();
            for (var i = 1; i < n; i++)
            {
                var s1 = s.Substring(0, i).Distinct().ToArray();
                var s2 = s.Substring(i).Distinct().ToArray();
                var count = 0;
                for (var j = 0; j < s1.Length; j++)
                {
                    if (s2.Contains(s1[j]))
                    {
                        count++;
                    }
                }
                result = Math.Max(result, count);
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 28188
def main():
    n = input()
    m = int(n[-1])
    hon = [2, 4, 5, 7, 9]
    pon = [0, 1, 6, 8]
    if m in hon:
        print('hon')
    elif m in pon:
        print('pon')
    else:
        print('bon')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9088
import java.util.*;

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


Measured memory_bytes: 71548
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let input: u32 = read();
    let mut answer: u32 = 0;
    if input % 2 == 0 {
        answer = input;
    } else {
        answer = input * 2;
    }
    
    println!("{}", answer);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  string S;
  cin >> S;
  int x,y;
  cin >> x >> y;
  vector<int> t;
  int cnt = 0;
  for(int i=0; i<S.size(); i++){
    if(S[i] == 'T'){
      if(cnt != 0) t.push_back(cnt);
      t.push_back(0);
      cnt = 0;
    }else{
      cnt++;
      if(i == S.size()-1) t.push_back(cnt);
    }
  }
  const ll MAXN = 8020;
  vector<bitset<MAXN*2>> dp_x(MAXN),dp_y(MAXN);
  dp_x[0][8000] = true;
  dp_y[0][8000] = true;
  bool flag = false;
  bool xy = true;
  int cnt_x=0,cnt_y=0;
  for(int i=0; i<t.size(); i++){
    if(t[i] == 0){
      xy = !xy;
    }else if(xy){
      cnt_x++;
      for(int j=0; j<MAXN*2; j++){
        if(dp_x[cnt_x-1][j]){
          if(j+t[i] < MAXN*2) dp_x[cnt_x][j+t[i]] = true;
          if(j-t[i] >= 0 and flag) dp_x[cnt_x][j-t[i]] = true;
        }
      }
    }else if(!xy){
      cnt_y++;
      for(int j=0; j<MAXN*2; j++){
        if(dp_y[cnt_y-1][j]){
          if(j+t[i] < MAXN*2) dp_y[cnt_y][j+t[i]] = true;
          if(j-t[i] >= 0) dp_y[cnt_y][j-t[i]] = true;
        }
      }
    }
    if(!flag) flag = true;
  }
  cout << ((dp_x[cnt_x][x+8000] and dp_y[cnt_y][y+8000]) ? "Yes" : "No") << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> card(N);
  for (int i = 0; i < N; i++) {
    cin >> card.at(i);
  }
      
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  
  int Alice = 0;
  int Bob = 0;

  for (int k = 0; k < N; k += 2) {
    Alice += card.at(k);
  }
  
  for (int j = 1; j < N; j += 2) {
    Bob += card.at(j);
  }
  
  cout << Alice - Bob << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ll k;
  cin >> k;
  ll a[k];
  for (ll i=0; i<k; ++i) cin >> a[i];
  if (a[k-1] > 2) {
    cout << -1 << endl;
    return 0;
  }
  ul t=2, b=2;
  for (ll i=k-1; i>=0; --i) {
    b = ((b-1)/a[i]+1) * a[i];
    t = (t/a[i]) * a[i] + a[i] - 1;
    if (b > t) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << b << " " << t << endl;
  return 0;
}


Measured memory_bytes: 1024
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

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

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;

template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void yesno(bool c) { OUT(c ? "yes" : "no"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	REP(i, B + 1) {
		if (A*i%B == C) {
			OUT("YES");
			return 0;
		}
	}
	OUT("NO");
	return 0;
}

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



int main(){
  int N;
  cin>>N;
  
  vector<int> jun(N);
  for(int i=0;i<N;i++){
    jun.at(i)=i+1;
  }
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int kai=0;
  int ren=0;
  for(int i=0;i<N;i++){
    if(jun.at(i)==vec.at(i)) ren++;
    else{
      kai+=(ren+1)/2;
      ren=0;
    }
  }
  kai+=(ren+1)/2;
  cout<<kai<<endl;
}

Measured memory_bytes: 4012
def insertion_sort(arr):
  print(" ".join(map(str, arr)))
  for i in range(1, len(arr)):
    key = arr[i]
    j = i - 1
    while j >= 0 and arr[j] > key:
      arr[j + 1] = arr[j]
      j -= 1
    arr[j + 1] = key
    print(" ".join(map(str, arr)))

n = int(input())
arr = list(map(int, input().split()))
insertion_sort(arr)

Measured memory_bytes: 7688
#include <cstdio>
#include <algorithm>
int N, M, a[100], b[100];
int main()
{
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++)
		scanf("%d", a + i);
	if (M == 1)
	{
		if (N == 1)
			puts("1\n1\n1");
		else
			printf("%d\n2\n1 %d\n", N, N - 1);
		return 0;
	}
	int Odd = std::count_if(a, a + M, [] (int x) { return x & 1; });
	if (Odd > 2)
	{
		puts("Impossible");
		return 0;
	}
	if (Odd == 2)
	{
		int C = 1;
		for (int i = 0; i < M; i++)
			if (!(a[i] & 1))
				b[C++] = a[i];
			else
				(b[0] ? b[M - 1] : b[0]) = a[i];
		for (int i = 0; i < M; i++)
			printf("%d%c", b[i], " \n"[i == M - 1]);
		b[0]++;
		b[M - 1]--;
		if (!b[M - 1])
			M--;
		printf("%d\n", M);
		for (int i = 0; i < M; i++)
			printf("%d%c", b[i], " \n"[i == M - 1]);
		return 0;
	}
	if (Odd == 1)
	{
		int C = 1;
		for (int i = 0; i < M; i++)
			if (!(a[i] & 1))
				b[C++] = a[i];
			else
				b[0] = a[i];
		for (int i = 0; i < M; i++)
			printf("%d%c", b[i], " \n"[i == M - 1]);
		b[0]++;
		b[M - 1]--;
		printf("%d\n", M);
		for (int i = 0; i < M; i++)
			printf("%d%c", b[i], " \n"[i == M - 1]);
		return 0;
	}
	for (int i = 0; i < M; i++)
		printf("%d%c", a[i], " \n"[i == M - 1]);
	a[0]++;
	a[M - 1]--;
	printf("%d\n", M);
	for (int i = 0; i < M; i++)
		printf("%d%c", a[i], " \n"[i == M - 1]);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
 
int main()
{
    int a,i;
    double j=0.0,sum=0.0;
    int c[100];
    std::cin>>a;
    for(i=0;i<a;i++)
    {
       std::cin>>c[i];
    }
    for(i=0;i<a;i++)
    {
        j=j+(1.0/c[i]);
    }
    sum=1.0/j;
    std::cout<<sum;
    return 0;
}

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

vector<vector<bool> > graph (51, vector<bool> (51, false));
vector<pair<int, int> > graph_numbers;
int bridges = 0;
int n, edges;

bool visited[51] = {false};
void dfs(int start){
  if (visited[start] == true){
    return;
  }
  visited[start] = true;
  for (int i=1; i<=n; i++){
    if (graph[start][i] == true){
      
      dfs(i);
    }
  }
}
int main(){
  cin >> n >> edges;
  for (int i=0; i<edges; i++){
    int p1, p2;
    cin >> p1 >> p2;
    graph[p1][p2] = true;
    graph[p2][p1] = true; // using indexes to easily delete edge
    graph_numbers.push_back(make_pair(p1, p2));
  }
  for (int i=0; i<edges; i++){ 
    for (int j=1; j<=n; j++){
      visited[j] = false;
    }
    int v1 = graph_numbers[i].first;
    int v2 = graph_numbers[i].second;
    
    graph[v1][v2] = false;
    graph[v2][v1] = false;
    dfs(1);
    graph[v1][v2] = true;
    graph[v2][v1] = true;
    for (int j=1; j<=n; j++){
      if (visited[j] == false){
        bridges++;
        break;
      }
    }
   }
  cout << bridges;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,ln,point=0;
    string str;
    cin>>str;
    ln = str.size();
    char str2[ln];
    int k=0;
    for(i=0;i<ln;i++){
        if(str[i]=='0'){
            str2[k]='0';
            k++;
        }
        else if(str[i]=='1'){
            str2[k]='1';
            k++;
        }
        else if(str[i]=='B'){
            if(k>0){
                k--;
            }
        }
    }
    for(i=0;i<k;i++){
        cout<<str2[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
// NOTE: one-indexed
template <typename T> struct bit {
    const int n;
    vector<T> t;
    bit(int n) : n(n), t(n + 1) {}
    void add(int i, T value) {
        for(int j = i; j <= n; j += j & -j) {
            t[j] += value;
        }
    }
    T sum(int i) {
        T res = 0;
        for(int j = i; j > 0; j -= j & -j) {
            res += t[j];
        }
        return res;
    }
    T sum(int L, int R) {
        return sum(R) - sum(L - 1);
    }
};
// NOTE: one-indexed
template <typename T> struct range_bit {
    bit<T> t;
    range_bit(int n) : t(bit<T>(n)) {}
    void add(int L, int R, T value) {
        t.add(L, value);
        t.add(R + 1, -value);
    }
    T get(int i) {
        return t.sum(i);
    }
};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> L(n), R(n), len(n), I(n);
    range_bit<int> b(m);
    for(int i = 0; i < n; i++) {
        cin >> L[i] >> R[i];
        len[i] = R[i] - L[i] + 1;
        b.add(L[i], R[i], 1);
    }
    iota(I.begin(), I.end(), 0);
    sort(I.begin(), I.end(), [&](int i, int j) {
        return len[i] < len[j];
    });
    vector<int> ans(m + 1);
    int removed = 0;
    for(int d = m; d >= 1; d--) {
        while(not I.empty() and len[I.back()] >= d) {
            b.add(L[I.back()], R[I.back()], -1);
            I.pop_back();
            removed++;
        }
        ans[d] = removed;
        for(int x = 0; x <= m; x += d) {
            ans[d] += b.get(x);
        }
    }
    for(int d = 1; d <= m; d++) {
        cout << ans[d] << endl;
    }
    return 0;
}


Measured memory_bytes: 6400
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

char s[100000];

int main(){
	int flag = 0;
	scanf("%s",s + 1);
	int len = strlen(s + 1);
	for(int i = 1;i <= len;i++){
		if(s[i] != s[len - i + 1]) flag = 1;
	}
	if(flag) printf("No");
	else printf("Yes");
}

Measured memory_bytes: 256
import Control.Monad

main = do
  _ <- getLine
  numbers <- fmap (map read . words) $ getLine
  let possibleAdditions = map addAll . filterM (\x -> [True, False]) $ numbers
  _ <- getLine
  targets <- fmap (map read . words) $ getLine
  mapM_ putStrLn $ map (yesno . (`elem` possibleAdditions)) targets

addAll :: [Int] -> Int
addAll [] = 0
addAll xs = foldl (+) 0 xs

yesno :: Bool -> String
yesno True  = "yes"
yesno False = "no"

Measured memory_bytes: 114676
N = int(input())
B =list(map(int,input().split()))
ans = 0
A = [0]*N
A[0] = B[0]
for i in range(1,N-1):
    if B[i] < B[i-1]:
        A[i] = B[i]
    else:
        if B[i] == A[i]:
            A[i] = A[i-1]
        else:
            A[i] = B[i-1]
A[N-1] = B[N-2]
ans = sum(A)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
 
int main(void)
{
    double r, S, L;
    scanf("%lf", &r);
     
    S = (double)r * r * 3.141592653589;
    L = (double)r * 2 * 3.141592653589;
     
    printf("%f %f", S, L);
     
    return 0;
}

Measured memory_bytes: 648
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

A, B = map(int, input().split())

ans = sorted([str(A)*B, str(B)*A])
print(ans[0])

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


int main(){
	
	string a , b ;
	cin>>a>>b;
	if((a.length ())==(b.length ()))
{
		if(a > b)
	  cout<<"GREATER";
else
if(a<b)
  cout<<"LESS";   
else 
if(a==b)
cout<<"EQUAL";
}
else 
if((a.length ())>(b.length ()))
cout<<"GREATER";
else
if((a.length ())<(b.length ()))
cout<<"LESS";
}


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

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  uint64_t g = gcd(m,n);
  if(m%g==0) return (m/g)*n;
  if(n%g==0) return (n/g)*m;
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  string s;
  cin >> s;

  int count = 0;
  for(int i=1;i<s.length();i++){
    if(s[i]!=s[i-1]) count++;
  }
  
  cout << count << endl;

  return 0;
}



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

using namespace std;

int main(void)
{
    string str;
    map<string, int> cnt;
    string freq;
    string maxlen;
    while(cin >> str) {
        int c = cnt[str]++;

        if(c > cnt[freq])
            freq = str;
        if(str.size() > maxlen.size())
            maxlen = str;
    }
    cout << freq << " " << maxlen << endl;

    return 0;
}

Measured memory_bytes: 1196
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
//            while (true)// MAKE SURE TO REMOVE THIS
                solve(in);
        }
    }

    private static void solve(Scanner in) {
        int a = in.nextInt() * in.nextInt();
        int c = in.nextInt() * in.nextInt();
        System.out.println(a > c ? a : c);
    }
}

Measured memory_bytes: 9172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using ll = long long;
using ull = unsigned long long;

using namespace std;

int main(int argc, char const *argv[]) {
	int n;
	std::cin >> n;
	std::vector<int> v(n);
	int sum = 0;
	for (size_t i = 0; i < n; i++) {
		std::cin >> v[i];
		sum += v[i];
	}
	std::cout << sum - n << '\n';
	return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
from itertools import combinations
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
ans = 0
s = Counter(list(accumulate([0]+a))).most_common()
for k,v in s:
  if  v>=2:
    ans += int(v*(v-1)//2)
  else:
    break
print(ans)

Measured memory_bytes: 48144
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef vector<int> vi;
#define pb push_back
typedef long long ll;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,m,a[N],b[N],fa[N],id[N];
ll s[N],f[N];
vi E[N];
bool vis[N];

int getf(int x) {
	return x==fa[x]?x:fa[x]=getf(fa[x]);
}

bool cmp(int x,int y) {
	return a[x]<a[y];
}

int main() {
	cin>>n>>m;
	for(int i=1;i<=n;i++) {
		a[i]=gi(),b[i]=gi();
		a[i]=max(a[i]-b[i],0);
		id[i]=fa[i]=i;s[i]=b[i];f[i]=a[i];
	}
	for(int i=1,u,v;i<=m;i++) u=gi(),v=gi(),E[u].pb(v),E[v].pb(u);
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++) {
		int u=id[i];vis[u]=1;
		for(auto v:E[u])
			if(vis[v]) {
				int x=getf(u),y=getf(v);
				if(x!=y) {
					s[x]+=s[y];fa[y]=x;f[x]=min(f[x],max(f[y],a[x]-s[y]));
				}
			}
	}
	int x=getf(1);cout<<f[x]+s[x];
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> W(N);
  int sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> W[i];
    sum += W[i];
  }
  int tmp = W[0];
  int absmin = abs(tmp - (sum - tmp));
  for(int i = 1; i < N; i++) {
    int absv = abs(tmp - (sum - tmp));
    absmin = min (absmin,absv);
    tmp += W[i]; 
  }
  cout << absmin << endl;
}

Measured memory_bytes: 256