akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int

ll solve(int i,int w,int n,vector<int>&wts,vector<int>&vals)
{
    if(i==n) return 0;

    ll skip_current = solve(i+1,w,n,wts,vals);

    ll add_current = INT_MIN;
    if(wts[i] <= w)
    {
        add_current = vals[i] + solve(i+1,w-wts[i],n,wts,vals);
    }

    return max(skip_current,add_current);
}


int main()
{
	FASTIO; 

    int n,w;
    cin>>n>>w;

	vector<int> val(n);
    vector<int> wts(n);

    for(int i = 0;i<n;i++)
    {
        cin>>wts[i]>>val[i];
    }

    // 1. Recusive
    // cout<<solve(0,w,n,wts,val);

    // 2. 2D - DP
    // vector<vector<ll>> dp(n+1,vector<ll>(w+1,0));

    // for(int i = n-1;i>=0;i--)
    // {
    //     for(int wt = w;wt>=0;wt--)
    //     {
    //         ll skip_current = dp[i+1][wt];

    //         ll add_current = INT_MIN;
    //         if(wts[i] <= wt)
    //         {
    //             add_current = val[i] + dp[i+1][wt-wts[i]];
    //         }

    //         dp[i][wt] = max(skip_current,add_current);
    //     }
    // }

    // for(auto vec : dp)
    // {
    //     for(auto ele : vec) cout<<ele<<" ";
    //     cout<<endl;
    // }

    // cout<<dp[0][w];

    // 3. Linear space DP
    vector<ll> dp (w+1,0);

    for(int i = n-1;i>=0;i--)
    {
        for(int wt = w;wt>=0;wt--)
        {

            ll add_current = INT_MIN;
            if(wts[i] <= wt)
            {
                add_current = val[i] + dp[wt-wts[i]];
            }

            dp[wt] = max(dp[wt],add_current);
        }
    }

    cout<<dp[w];

}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>p;
struct edge { int to, cost; };

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool f = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";

int main() {
	int n;
	char s[1000];
	std::cin >> n;
	for (int i = 0;i < n;i++) {
		std::cin >> s[i];
		if (s[i] == 'Y')flag = false;
	}
	if (flag)std::cout << "Three" << std::endl;
	else std::cout << "Four" << std::endl;

	}

Measured memory_bytes: 256
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
 
 
n,w = map(int,input().split()) #n:頂点数　w:辺の数
 
d = [[float("inf")]*n for i in range(n)]

E = [tuple(map(int, input().split())) for _ in range(w)]

#d[u][v] : 辺uvのコスト(存在しないときはinf)
for x,y,z in E:
    d[x-1][y-1] = z
    d[y-1][x-1] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０

root = warshall_floyd(d)

ans = 0

for x,y,z in E:
    if d[x-1][y-1] != z:
        ans += 1
print(ans)

Measured memory_bytes: 74464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N; cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> B[i];
    }   
    vector<iint> C(N);
    for (int i = 0; i < N; i++) {
        C[i].first = B[i];
        C[i].second = A[i];
    }

    sort(ALL(A));
    sort(ALL(B));
    bool check = true;
    for (int i = 0; i < N; i++) {
        if(A[i] > B[i]){
            check = false;
        }
    }
    if(check == false){
        No();
        return 0;
    }
    sort(ALL(C));

    map<ll, int> m;
    for (int i = 0; i < N; i++) {
        m[A[i]] = i;
    }
    int cnt = 1;
    int tmp = m[C[0].second];    
    while(tmp != 0) {
        tmp = m[C[tmp].second];
        cnt++;
    }
    if(cnt != N){
        Yes();
        return 0;
    }
    for (int i = 0; i < N-1; i++) {
        if(A[i+1] <= B[i]){
            Yes();
            return 0;
        }
    }
    No();


}

Measured memory_bytes: 11028
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll n,p=1e9+7;
  cin>>n;
  vector<P> v;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    v.pb(P(a,1));
  }
  for(int i=0;i<n;i++){
    ll b;
    cin>>b;
    v.pb(P(b,-1));
  }
  sort(all(v));
  
  vector<ll> lap;
  ll sum=0;
  for(int i=0;i<v.size();i++){
    ll tmp=sum;
    sum+=v[i].second;
    if(sum==0)continue;
    if(abs(tmp)<abs(sum))lap.pb(abs(sum));
  }
  
  ll ans=1;
  for(int i=0;i<lap.size();i++){
    ans*=lap[i];
    ans%=p;
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 6128
import sys
from collections import deque

sys.setrecursionlimit(100000000)
n = int(input())
G = [[] for _ in range(n)]  # 頂点の個数分準備
for i in range(n - 1):  # 辺の数はn-1
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append([v, w])
    G[v].append([u, w])
ans = [-1] * n
ans[0] = 0
que = deque([0])
while que:
    tmp = que.popleft()  # 幅優先探索
    for u, w in G[tmp]:
        if ans[u] != -1:  # すでに訪問済みの時
            continue
        ans[u] = ans[tmp] + w  # 辺の長さを追加
        que.append(u)  # queに追加

for c in ans:
    if c % 2 == 0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 49332
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Sagor
 */

#include <fstream>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
typedef long long int ll;
typedef double ld;
using namespace std;

class ANextAlphabet {
public:
	void solve(std::istream& in, std::ostream& out) {
	    char c;
	    in>>c;
	    printf("%c\n",c+1);

	}
};


int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
	ANextAlphabet solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
N,K = [int(i) for i in input().split()]
ablist = []
for i in range(N):
    ablist.append([int(i) for i in input().split()])

counter = [0 for i in range(110000)]
for a,b in ablist:
    counter[a]+=b

for i in range(110000):
    K-=counter[i]
    if K<=0:
        print(i)
        break

Measured memory_bytes: 24084
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < n; i++) 
#include <string>
#include <deque>
using namespace std;
//#pragma GCC optimize("Ofast")

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int q, t, f;
    string a;
    cin >> a >> q;
    deque<char> s;
    for (auto i = a.begin(); i != a.end(); i++) {
        s.push_back(*i);
    }
    int frag = 1;
    char c;
    rep(i, q) {
        cin >> t;
        if (t == 2) {
            cin >> f;
            if (f == 1) {
                cin >> c;
                if (frag==-1) {
                    s.push_back(c);
                } else if (frag==1) {
                    s.push_front(c);
                }
            } else if (f == 2) {
                cin >> c;
                if (frag==-1) {
                    s.push_front(c);
                } else if (frag==1) {
                    s.push_back(c);
                }
            }
        } else if (t==1) {
            frag*=-1;
        }
    }

    if (frag==-1) {
        reverse(s.begin(), s.end());
        for (auto i = s.begin(); i != s.end(); i++) {
            cout <<  *i;
        }
    } else if (frag==1) {
        for (auto i = s.begin(); i != s.end(); i++) {
            cout << *i;
        }
    }
    return 0;
}

Measured memory_bytes: 976
n,k=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
ans=0
arr=sorted(arr,key=lambda x:x[0],reverse=True)
amax=arr[0][0]
arr=sorted(arr,key=lambda x:x[1],reverse=True)
bsum=0
for i in range(n):
  if amax>=arr[i][1]:
    break
  bsum+=arr[i][1]
  ans+=1
  if bsum>=k:
    break
if bsum>=k:
  print(ans)
else:
  if (k-bsum)%amax==0:
    ans+=(k-bsum)//amax
  else:
    ans+=(k-bsum)//amax+1
  print(ans)

Measured memory_bytes: 29808
//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)

#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) (ll)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0

typedef double db;
typedef long long ll;

const ll ary=1e5+5;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
using namespace __gnu_pbds;
ll n,m,p[ary];
string s;
vector<ll> t(4*ary,inf),q,d(ary,inf);
map<ll,ll> mp;
void upd(ll pos,ll x,ll v=1,ll tl=0,ll tr=n){
	if(tr<pos||pos<tl){
		return;
	}
	if(tl==tr){
		t[v]=x;
		return;
	}
	ll tm=(tl+tr)/2;
	upd(pos,x,v*2,tl,tm);
	upd(pos,x,v*2+1,tm+1,tr);
	t[v]=min(t[v*2],t[v*2+1]);
}
ll get(ll l,ll r,ll v=1,ll tl=0,ll tr=n){
	if(r<tl||tr<l){
		return inf;
	}
	if(l<=tl&&tr<=r){
		return t[v];
	}
	ll tm=(tl+tr)/2;
	return min(get(l,r,v*2,tl,tm),get(l,r,v*2+1,tm+1,tr));
}
int main(){
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);cout.tie(0);
	cin>>n>>m>>s;
	upd(n,0);
	d[n]=0;
	for(int i=n-1;i>=0;i--){
		if(s[i]=='1'){
			continue;
		}
		d[i]=get(i+1,min(i+m,n))+1;
		upd(i,d[i]);	
	}
	if(d[0]>=inf){
		cout<<-1;
		return 0;
	}
	mp[0]=n;
	for(int i=n-1;i>=0;i--){
		if(d[i]>=inf){
			continue;
		}
		p[i]=mp[d[i]-1];
		mp[d[i]]=i;	
	}
	ll v=0;
	while(v!=n){
		q.putb(v);
		v=p[v];
	}
	q.putb(n);
	for(int i=1;i<len(q);i++){
		cout<<q[i]-q[i-1]<<" ";
	}
}

Measured memory_bytes: 12412
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll mod = 1e9+7;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int>a(n),b(m);
    rep(i,n)cin >> a[i];
    rep(i,m)cin >> b[i];
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    a.push_back(-1);
    b.push_back(-1);
    rep(i,n-1){
        if(a[i] == a[i+1]){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i,m-1){
        if(b[i] == b[i+1]){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    ll i = 0,j = 0;
    for(ll num = n*m; num > 0; num--){
        if(a[i] == num and b[j] == num){
            i++,j++;
        }else if(a[i] == num){
            i++;
            ans *= j;
        }else if(b[j] == num){
            j++;
            ans *= i;
        }else{
            ans *= (i*j-(n*m-num))%mod;
        }
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //__gnu_pbds::gp_hash_table<int, int> table;
//priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;  //min heap

typedef int OwO;
typedef double UwU;

#define int long long
#define double long double
#define INF 1000000000
#define PI 3.14159265358979323846
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vi vector<int>

using namespace std;

OwO main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M;
  cin >> N >> M;
  int lower = -INF;
  int upper = INF;
  while(M--){
    int l,r;
    cin >> l >> r;
    lower = max(lower, l);
    upper = min(upper, r);
  }
  if(lower > upper)
    cout << 0 << endl;
  else
    cout << upper-lower+1 << endl;

  return 0;
}

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

nList = [i + 1 for i in range(N)]
res = -1
counter = -1
for n in nList :
    count = 0
    buf = n
    while buf % 2 == 0 :
        count += 1
        buf = buf / 2
    if counter < count :
        counter  = count
        res = n
print(res)


Measured memory_bytes: 2940
A, B, K = map(int, input().split())
for n in range(A, A + K):
    if B >= n:
        print(n)
if A + K > B:
    K = 0
elif A + K > B - K:
    K = B - A - K + 1
for n in range(B - K + 1, B + 1):
    print(n)

Measured memory_bytes: 3060
<?php
$n=trim(fgets(STDIN));
$s = 0;
$track = array("tr");
$sec = array("0");
for($i=0;$i<$n+1;++$i){
    fscanf(STDIN,"%s %d",$a,$b);
    
    array_push($track,$a);
    
    array_push($sec,$b);
}

$result = array_search($track[$n+1], $track);
for($j=0;$j<$result;$j++){
  $s = $s + $sec[$j+1];

}
$sum = array_sum($sec) - $sec[$n+1];
  $ans = $sum - $s;
  echo $ans;

?>


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int a,b; cin>>a>>b;
	int c;
	if(a>=13) c=b;
	else if(a>=6 and a<=12) c=b/2;
	else c=0;
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
import itertools

N = input()
dig = len(N)
N = int(N)

# 全探索
# 3^9 <= 20000
A = ['3','5','7']

def count_num(A,n):
  Comb = itertools.product(A, repeat=n)
  cnt = 0
  for X in Comb:
    X = list(X)
    X_num = int(''.join(X))
    if(X_num <= N):
      j3,j5,j7 = 0,0,0
      for x in X:   
        if(x == '3'): j3 = 1
        elif(x == '5'): j5 = 1
        elif(x == '7'): j7 = 1
      if(j3*j5*j7 == 1):
        cnt += 1
  return cnt      

ans = 0
for i in range(3,dig+1):
  ans += count_num(A,i)
print(ans)      

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

#define int long long
#define P(x) {if (debug) cout << x << endl;} 
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define D(i,n) for (int i=(n); i-->0;)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple

using namespace std;

template<class T> ostream& operator<<(ostream& os, V<T> v) {
F(i,S(v)) os<<(i?" ":"")<<v[i]; return os;}

const bool debug = 1;

int n;
int N;

signed main () {
    
    N = 30000;
    cin >> n;
	
	if(n == 3)  {
		cout << "2 5 63" << endl;
		return 0;
	}
	n = 20000 - n;
    vector <int> tab;
   // int sum = 0;
    
    set <int> removed;
    
    for(int i = 12; i <= N; i+=6) {
    	if(n < 3) break;
    	else {
    		n--;
    		removed.insert(i);
    	}
    	/*if(i%2 == 0 || i%3 == 0) {
    		if(S(tab) < n-2 ||((sum+i)%2 == 0 && (sum+i)%3 == 0) ) {
    			tab.pb(i);
    			sum += i;
    		}
    	}	
    	if(S(tab) ==  n) break;*/

    }

    for(int i= 29998; i >= 6; i-=6) {
    	if(n < 3) break;
    	else {
    		n-=2;
    		removed.insert(i);
    		removed.insert(i-2);
    	}
    }
    for(int i= 29997; i >= 9; i-= 12) {
    	if(n < 3) break;
    	else if(i-12 > 1) {
    		n-=2;
    		removed.insert(i);
    		removed.insert(i-6);
    	}
    }

	if(n == 1) {
		removed.insert(6);
		n-=2;
	}
	else if (n == 2) {
		removed.insert(3);
		removed.insert(9);
		n-=2;	
	}
	else if(n == 3) {
		removed.insert(2);
		removed.insert(4);
		removed.insert(6);
	}

    for(int i= 2; i <= N; i++) {
    	if((i%2 == 0 || i%3 ==0) && removed.count(i) == 0) tab.pb(i);
    }


    cout << tab << endl;
    //cout << S(tab) << endl;    
    
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i,0,m) cin >> b[i];


    int ans = 0;
    for(int i=0;i<n;i++){
        ll cur = 0;
        for(int j=0;j<m;j++){
            int a; cin >> a;
            cur += a*b[j];
        }
        if(cur+c > 0) ans++;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;i++)

const ll INF = 1001001001;

//提出のときに言語がc＋＋似合っていることを確認する

//絶対値の関数
int z(int a,int b){
  if(a>b) return a-b;
  else return b-a;
}





int main(){
  ll n;
  cin>>n;
  vector<ll>a(n-1);
  rep(i,n-1){
    cin>>a[i];
  }
  vector<ll>v(n,0);
  rep(i,n-1){
    v[a[i]-1]++;
  }
  rep(i,n){
    cout<<v[i]<<endl;
  }
  
}



Measured memory_bytes: 6300
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    string S;cin>>S;
    string tms = S;
    reverse(tms.begin(),tms.end());
    bool isS = true;
    if(S!=tms)isS=false;
    string a = S.substr(0,(S.size()-1)/2);
    tms = a;
    reverse(tms.begin(),tms.end());
    if(a!=tms)isS=false;
    a = S.substr((S.size()+3)/2-1);
    tms = a;
    reverse(tms.begin(),tms.end());
    if(a!=tms)isS=false;
    cout<<(isS?"Yes":"No")<<endl;
}

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

int main() {
  int N;
  int i, j, k;
    cin >> N;
  k = N;
  j = 0;
    for (i = N; i > 0; i/= 10) {
      j += k % 10;
      k = k / 10;
    }   //forの終わり
  if (N % j == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int value[2][4];
	int i,j,h=0,b=0,d=0;
	while(scanf("%d %d %d %d",&value[0][0],&value[0][1],&value[0][2],&value[0][3]) != EOF)
	{
		for(i=0;i<4;i++)
		{
			if(value[0][i]==EOF)
			{
				d==1;
				continue;
			}
		}		
		if(scanf("%d %d %d %d",&value[1][0],&value[1][1],&value[1][2],&value[1][3]) != EOF)
		for(i=0;i<4;i++)
		{
			if(value[1][i]==EOF)
			{
				d==1;
				break;
			}
		}
		for(i=0;i<4;i++)
		{
			for(j=0;j<4;j++)
			{
				if(value[0][i] == value[1][j])
				{
					if(i == j)
					{
						h++;
					}
					else
					{
						b++;
					}
				}
			}
		}
		printf("%d %d\n",h,b);
		h=0;b=0;
		if(d==1)
		{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 1e5+1;

ll N, M;
vi adj[MAX];
bool used[MAX];

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

  REP (i, M) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }

  REP (i, N) used[i] = false;

  vector<int> ans;
  ans.push_back(0);
  used[0] = true;
  while (true) {
    int last = ans.back();
    REP (i, adj[last].size()) {
      if (!used[adj[last][i]]) {
        ans.push_back(adj[last][i]);
        used[adj[last][i]] = true;
        break;
      }
    }
    if (ans.back() == last) break;
  }

  while (true) {
    int head = ans.front();
    REP (i, adj[head].size()) {
      if (!used[adj[head][i]]) {
        ans.insert(ans.begin(), adj[head][i]);
        used[adj[head][i]] = true;
        break;
      }
    }
    if (ans.front() == head) break;
  }

  cout << ans.size() << endl << ans[0]+1;
  FOR (i, 1, ans.size()) cout << " " << ans[i]+1;
  cout << endl;

  return 0;
}

Measured memory_bytes: 6904
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAXN 3005
#define INF 1000000000000000LL
#define MOD 1000000007
#define pb push_back
 
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
 
int n;
double v[MAXN];
double dp[MAXN][MAXN];
 
int main(){
	cin.tie(NULL);
	ios_base::sync_with_stdio(0);
 
	cin >> n;
 
	for(int i = 1; i <= n; i++) cin >> v[i];
 
	for(int i = (n / 2) + 1; i <= n; i++) dp[0][i] = 1LL;
 
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= n - i; j++){
			//cout << "i " << i << " j " << j << " : " << dp[i][j] << endl;
			dp[i][j] = dp[i - 1][j + 1] * v[i];
			dp[i][j] += dp[i - 1][j] * (1.0 - v[i]);
			//cout << "i " << i << " j " << j << " : " << dp[i][j] << endl;
		}
	}
 
	cout << fixed << setprecision(10) << dp[n][0] << endl;
 
	return 0;
}

Measured memory_bytes: 70016
def main():
    N = int(input())
    a = 0
    m = 0
    mi = 0
    mm = 0
    for i in range(N):
        a = int(input())
        if a > m:
            mm = m
            m = a
            mi = i
        elif a > mm:
            mm = a
    for i in range(N):
        if i == mi:
            print(mm)
        else:
            print(m)


main()


Measured memory_bytes: 4540
A,B,C = map(int,input().split())
L = [A,B,C]
L.sort()
if ((L[2]-L[1]) % 2 == (L[2]-L[0]) % 2 == 0):
  print((2*L[2]-L[1]-L[0])//2)
elif ((L[2]-L[1]) % 2 == (L[2]-L[0]) % 2 == 1):
  print(1+(2*L[2]-L[1]-L[0]-2)//2)
else:
  print(1+(2*L[2]-L[1]-L[0]+1)//2)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tok = new StringTokenizer(br.readLine());
        final int h = Integer.parseInt(tok.nextToken());
        final int w = Integer.parseInt(tok.nextToken());

        char[][] mat = new char[h][w];
        boolean[] row = new boolean[h];
        boolean[] col = new boolean[w];

        for (int i = 0; i < h; i++) {
            String str = br.readLine();
            for (int j = 0; j < w; j++) {
                char c = str.charAt(j);
                mat[i][j] = c;
                if (c == '#') {
                    row[i] = true;
                    col[j] = true;
                }
            }
        }

        for (int i = 0; i < h; i++) {
            if (!row[i]) continue;
            for (int j = 0; j < w; j++) {
                if (col[j]) {
                    System.out.print(mat[i][j]);
                }
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 23508
#import heapq



W,H=list(map(int,input().split()))





is_connected_X = [False for _ in range(W)]
count_connected_X = 0
is_connected_Y = [False for _ in range(H)]
count_connected_Y=0

P = [(i,int(input()),"W") for i in range(W)]
Q = [(j,int(input()),"H") for j in range(H)]

PQ = sorted(P+Q, key=lambda x:x[1])

total_cost=0
for i,cost,wh in PQ:

    if wh=="W":
        count_connected_X+=1
        is_connected_X[i]=True
        total_cost+= cost*(H+1-count_connected_Y)
    elif wh=="H":
        count_connected_Y += 1
        is_connected_Y[i] = True
        total_cost += cost * (W + 1 - count_connected_X)

print(total_cost)

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

def counter_list(A):
 def counter_dic(A): #counter 辞書
  dic = {}
  for a in A:
   dic[a] = dic.get(a,0) + 1
  return dic

 dic_ = counter_dic(A)
 B = []
 for k in dic_:
  B.append([k,dic_[k]])
 return B

#（発想）数値を全部追加してソート、大きい順に「Aの要素数」分の要素をとってきて和を求める
A = counter_list(A) 
for i in range(M):
 B,C = map(int,input().split())
 A.append([C,B]) #[C(数値),B(個数)]
 
A.sort(reverse = True) #降順ソート

num,n_index = 0,0 #num:現在和をとった要素の個数,n_index:現在の要素のインデックス
ans = 0 #求める和 
while(1):
  if(num == N): break
  if((N-num) >= A[n_index][1]):
   #N-num :残り必要な要素数
   #A[n_index][1] : 要素A[n_index][0]の個数
   ans += A[n_index][0]*A[n_index][1]
   num += A[n_index][1]
  else:
   ans += A[n_index][0]*(N-num)
   num = N
  n_index += 1 #indexを1つ進める
  
print(ans)

Measured memory_bytes: 33964
#include <bits/stdc++.h>
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define rep(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a,const T &b){
    if(a>b)return false;
    a=b;
    return true;
}
template<class T>bool chmin(T &a,const T &b){
    if(a<b)return false;
    a=b;
    return true;
}

const ll mod=1e9+7;
const ll inf=1ll<<60;

/*---------------------*/

struct LR{
    ll l,r;
    bool operator<(const LR&right)const{return r!=right.r?r<right.r:l>right.l;}
};

ll n,mxl=-inf,mnr=inf,ans;
vector<LR> p;

int main(){
    cin>>n;
    p.resize(n);
    rep(i,n){
        cin>>p[i].l>>p[i].r;
        p[i].l--;
        chmax(mxl,p[i].l);
        chmin(mnr,p[i].r);
        chmax(ans,p[i].r-p[i].l);
    }
    ans+=max(0ll,mnr-mxl);
    rep(i,n){
        p[i].l=max(0ll,mnr-p[i].l);
        p[i].r=max(0ll,p[i].r-mxl);
    }
    sort(p.begin(),p.end());

    ll mn=inf;
    rep(i,n-1){
        chmin(mn,p[i].l);
        chmax(ans,p[i+1].r+mn);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
import numpy as np
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

ans = 0
counter = Counter(A)
for a, cnt in counter.most_common():
    tmp = counter[a-1] + cnt + counter[a+1]
    if ans < tmp:
        ans = tmp
        

print(ans) 

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

typedef long long ll;

ll pow(ll x, ll n) {
  if ( n == 0 ) return 1;
  ll res = pow(x*x,n/2);
  if(n&1) res = res*x;
  return res;
}

int main() {
  int N; cin >> N;
  int P; cin >> P;
  ll even =0,odd = 0;
  for ( int i = 0; i < N; i++ ) {
    int A; cin >> A;
    if ( A % 2 == 0 )even++;
    else odd++;
  }

  if ( odd == 0 ) {
    if ( P == 0 ) cout << pow(2,N) << endl;
    else cout << 0 << endl;
  } else {
    cout << pow(2,N-1) << endl;
  }
  return 0;
}


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

int main() {
  char al[26]={'a','b','c','d','e','f','g',
	       'h','i','j','k','l','m','n',
	       'o','p','q','r','s','t','u',
	       'v','w','x','y','z'};
  char input;
  char ans;
  cin >> input;
  for(int i = 0;i<26;i++){
    if(input == al[i]){
      ans = al[i+1];
      break;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import heapq

n,m=map(int,input().split())
job=[]
que=[]
heapq.heapify(que)
for i in range(n):
    a,b=map(int,input().split())
    job.append([a,b])
job.sort()
point=0
idx=0
for i in range(m):
    while(idx<n and job[idx][0]<=i+1):
        heapq.heappush(que,-1*job[idx][1])
        idx+=1
    if que:
        point+=heapq.heappop(que)*-1
print(point)

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

int main(){   
   int n,ans=0,tep;
   cin >> n;
   tep=n;
   for(int i=0;i<11;i++){
       ans+=tep%10;
       if(tep/10==0){break;}
       tep=tep/10;
   }
   if(n%ans==0){cout << "Yes" <<endl;}else{cout << "No" <<endl;}
}

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

int d[50];
int main(void){
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> d[i];
    
    long long int value = 0;
    for (int i = 0; i < N-1; i++)
        for (int j = i+1; j < N; j++)
            value += d[i] * d[j];
    cout << value << endl;
}

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

const long long MAXCOUNT=(long long) 1e9+7;

int main(){
    string S;
    cin >> S;
    long long count=0;

    int N= (int) S.size();
    long long dp[N+1][13];

    for(int i=0; i<=N; i++){
        for(int j=0; j<13; j++){
            dp[i][j]=0;
        }
    }

    dp[0][0]=1;

    for(int i=0; i<N; i++){
        for(int j=0; j<13; j++){
            if( S[i]!='?' ){
                int tmp = ( j*10 + ( (int) S[i]-'0' ) )%13;
                dp[i+1][tmp] = dp[i][j];
            }else{
                for(int k=0; k<=9; k++){
                    int tmp = ( j*10 + k )%13;
                    dp[i+1][tmp] += dp[i][j];
                    dp[i+1][tmp]%=MAXCOUNT;
                    //cout << "i+1 j k tmp dp dp+ " << i+1 << " " << j << " " << k << " " << tmp << " " << dp[i][j] << " " << dp[i+1][tmp] << endl; 
                }
            }
        }
    }

    cout << dp[N][5] << endl;

    return 0;
}

Measured memory_bytes: 10624
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
#include <iterator>

using namespace std;

namespace {

}

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

	// vector<long long> a(N, 0);

	int num4 = 0;
	int numOdd = 0;
	for (int i = 0; i < N; ++i){
		long long curValue = 0;
		cin >> curValue;
		
		if (curValue % 4 == 0){
			++num4;
		}
		else if (curValue % 2 != 0){
			++numOdd;
		}
	}

	if (N % 2 != 0){ // 全体が奇数個の場合
		if (num4 >= numOdd - 1){
			cout << "Yes" << endl;
			return 0;
		}
	}
	else {
		if (num4 >= numOdd){
			cout << "Yes" << endl;
			return 0;
		}
	}
		
	cout << "No" << endl;

	return 0;
}

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

#define mp make_pair
#define eb emplace_back
#define x first
#define y second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
#define int long long
const int INF = 1e18;


typedef pair<int, int> pt;
void solve(){
  int n;
  cin >> n;
  vector<pt> a(n);
  for (int i = 0; i < n; i++) cin >> a[i].x >> a[i].y;

  map<int, int> mxy;
  auto add = [&](int x, int y){
    if (!mxy.count(x)) mxy[x] = y;
    mxy[x] = max(mxy[x], y);
  };
  for (auto i : a) add(i.x, i.y);
  
  map<int, int> mny;
  auto add2 = [&](int x, int y){
    if (!mny.count(x)) mny[x] = y;
    mny[x] = min(mny[x], y);
  };
  for (auto i : a) add2(i.x, i.y);
  
  int ans = 0;
  int mx = -INF;
  auto it = begin(mxy);
  for (auto i : mny){
    while (it != end(mxy) && it->x <= i.x){
      mx = max(mx, -it->x + it->y);
      it++;
    }
    ans = max(ans, mx + i.x - i.y);
  }
  
  int mx2 = -INF;
  auto it2 = begin(mny);
  for (auto i : mxy){
    while (it2 != end(mny) && it2->x <= i.x){
      mx2 = max(mx2, -it2->x - it2->y);
      it2++;
    }
    ans = max(ans, mx2 + i.x + i.y);
  }

  //for (auto i : a) ans = max(ans, mx - i.x - i.y);

  cout << ans << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


Measured memory_bytes: 31468
INTEGER N,Q
CHARACTER(100000) S
INTEGER L,R
INTEGER,ALLOCATABLE,DIMENSION(:)::CNT
INTEGER LL
READ*,N,Q
READ*,S
ALLOCATE(CNT(N))
CNT=0
LL=0
DO
  IF(INDEX(S(LL:),"AC")==0)EXIT
  CNT(LL+INDEX(S(LL:),"AC")-1:)=CNT(LL+INDEX(S(LL:),"AC")-1:)+1
  LL=LL+INDEX(S(LL:),"AC")
END DO
CNT(0)=0
DO I=1,Q
  READ*,L,R
  PRINT"(I0)",CNT(R-1)-CNT(L-1)
END DO
END

Measured memory_bytes: 1572
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

#define int long long

using namespace std;


class Solver {
};

signed main() {
	int n, q;
	cin >> n >> q;

	vector<int> cs(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> cs[i];
	}
	sort(cs.begin(), cs.end());

	vector<int> qs(q, 0);
	for (int i = 0; i < q; i++) {
		cin >> qs[i];
	}

	for (int i = 0; i < q; i++) {
		int res = 0;
		for (int j = 1; qs[i] * j <= (cs[cs.size()-1] / qs[i] + 1) * qs[i]; j++) {
			int now = qs[i] * j;

			int bottom = 0;
			int top = n;
			while (bottom + 1 < top) {
				int mid = (bottom + top) / 2;

				if (cs[mid] < now)bottom = mid;
				else top = mid;
			}
			res = max(res, cs[bottom] % qs[i]);
		}

		cout << res << endl;
	}
}


Measured memory_bytes: 6048
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  map<string, int64_t> k;
  rep(i,n){
    string s;
    cin >> s;
    rep(i,10){
      rep(j,i){
        if(s[i]<s[j])swap(s[i],s[j]);
      }
    }
    k[s]++;
  }
  int64_t ans=0;
  // Keyの値が小さい順にループ
  for (auto p : k){
    auto key = p.first;
    auto value = p.second;
    ans+=value*(value-1)/2;
    // key, valueを使う
  }
  cout << ans << endl;
}  


Measured memory_bytes: 11136
N = int(input())
S = list(map(int,input().split()))

ans = 0
for C in range(1,N):
    dp = 0
    for k in range((N-1)//C):
        if (2*k-1)*C == N-1 or 2*k*C == N-1:
            break
        dp += S[N-1-C*k]+S[C*k]
        ans = max(ans,dp)

print(ans)

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

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

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


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

    int L, R, d;
    cin >> L >> R >> d;

    int result = 0;
    for(int i = L; i <= R; i++)
    {
        if(i % d == 0) result++;
    }
    std::cout << result << "\n";
    return 0;
}


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

Measured memory_bytes: 1592
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

int A, B;

int main() {
    cin >> A >> B;
    REP(i, 1, 10000 + 1) {
        int a, b;
        a = (float)i * 0.08f;
        b = (float)i * 0.1f;
        if (a == A && b == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main(){

	int a,b,c;
	int Buffer;
	int VirticalLine[30];
	int HorizonLine[30][2];
	char BB;
			
	
	
	cin>>a>>b;
	
	for(c=0;c<a;c++){
	VirticalLine[c] = c+1;
	}
	for(c=0;c<b;c++){
	cin>>HorizonLine[c][0]>>BB>>HorizonLine[c][1];
	}
	for(c=0;c<b;c++){

		Buffer = VirticalLine[HorizonLine[c][1]-1];
		VirticalLine[HorizonLine[c][1]-1] = VirticalLine[HorizonLine[c][0]-1];
		VirticalLine[HorizonLine[c][0]-1] = Buffer;

	}

	for(c=0;c<a;c++)
	{
	cout<<VirticalLine[c]<<endl;
	}

return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
bool card[4][13] = {false};


int conv(char suit){
    switch(suit){
    case 'S': return 0;
    case 'H': return 1;
    case 'C': return 2;
    case 'D': return 3;
    }
    return -1;
}

char conv(int suit){
    switch(suit){
    case 0: return 'S';
    case 1: return 'H';
    case 2: return 'C';
    case 3: return 'D';
    }
    return -1;
}

int main(){

	int num;
    cin >> num;
    for(int i=0;i<num;i++){
        char s;
        int n;
        cin >> s >> n;
        card[conv(s)][n-1] = true;
	}
    
    for(int i=0;i< sizeof(card)/sizeof(card[0]);i++){
        for(int j=0;j<sizeof(card[0])/sizeof(card[0][0]);j++){
            if(card[i][j]==false)cout << conv(i) << " " << j+1 <<endl;
        }
    }
	return 0;
}


Measured memory_bytes: 3076
#include <algorithm>
#include <iostream>

using namespace std;

const int MAX_N = 300;

int n, m, k;
string s[MAX_N];
int cnt[26];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		for (int j = 0; j < s[i].size(); j++) {
			cnt[s[i][j] - 'a']++;
		}
	}
	if (n % 2 == 0 && m % 2 == 0) {
		for (int i = 0; i < 26; i++) {
			if (cnt[i] % 2 != 0) {
				cout << "No\n";
				return 0;
			}
			cnt[i] /= 2;
		}
		for (int i = 0; i < 26; i++) {
			if (cnt[i] % 2 != 0) {
				cout << "No\n";
				return 0;
			}
		}
		cout << "Yes\n";
		return 0;
	}
	if (n % 2 != 0 && m % 2 == 0) {
		swap(n, m);
	}
	if (n % 2 == 0 && m % 2 != 0) {
		for (int i = 0; i < 26; i++) {
			if (cnt[i] % 2 != 0) {
				cout << "No\n";
				return 0;
			}
			cnt[i] /= 2;
		}
		int ocnt = 0;
		for (int i = 0; i < 26; i++) {
			if (cnt[i] % 2 != 0) {
				ocnt++;
			}
		}
		if (ocnt <= n / 2 && (n / 2 - ocnt) % 2 == 0) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
		return 0;
	}
	int ocnt = 0;
	int tcnt = 0;
	for (int i = 0; i < 26; i++) {
		if (cnt[i] % 2 != 0) {
			ocnt++;
		} else if (cnt[i] % 4 != 0) {
			tcnt++;
		}
	}
	if (ocnt != 1) {
		cout << "No\n";
		return 0;
	}
	int sl = (n + m - 2) / 2;
	if (tcnt <= sl && (sl - tcnt) % 2 == 0) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(){
    int a, b, sum, idx = 0;
    for (; ;) {
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0) break;
        if (idx) printf("\n");
        if (a % 4 != 0) {
            while (1) { a++; if (a % 4 == 0) break; }
        }
        sum = 0;
        for (int i = a; i <= b; i+=4) {
            if (i % 100 == 0 && i % 400 != 0) continue;
            printf("%d\n", i);
            sum++;
        }
        if (sum == 0) printf("NA\n");
        idx++;
    }

    return 0;
}




Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IN(type, n) type n; cin >> n

int main() {
  IN(ll, N);
  vector<ll> A(N);
  REP(i, N) {
    cin >> A.at(i);
  }
  ll ans = 0;
  for (int i = 1; i < N; ++i) {
    if (A.at(i) < A.at(i - 1)) {
      ans += A.at(i - 1) - A.at(i);
      A.at(i) = A.at(i - 1);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  cin>>n>>k;
  int h[n],f[n];
  f[n-1] = 0;
  for(int i=0;i<n;i++)
  {
    cin>>h[i];
  }
  for(int i=n-2;i>=0;i--)
  {
    f[i]=INT_MAX;
    for(int j=i+1;j<=min(n-1,i+k);j++)
    {
      f[i] = min(f[j]+abs(h[i]-h[j]),f[i]);
    }
  }
  cout<<f[0]<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
typedef pair<int,int> P;
vector<P> G[1000];
int main(){
	while(true){
		int n,m,a;
		scanf("%d%d%d",&n,&m,&a);
		a--;
		if(n==0) break;
		rep(i,1000) G[i].clear();
		rep(i,m){
			int h,p,q;
			scanf("%d%d%d",&h,&p,&q);
			G[h-1].push_back(P(p-1,q-1));
		}
		rep(k,1000){
			int i=1000-1-k;
			rep(j,G[i].size()){
				if(G[i][j].fs==a) a=G[i][j].sc;
				else if(G[i][j].sc==a) a=G[i][j].fs;
			}
		}
		printf("%d\n",a+1);
	}
	return 0;
}

Measured memory_bytes: 1096
#include <stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if((a+b)%3==0) printf("Possible\n");
    else if(a%3==0) printf("Possible\n");
    else if(b%3==0) printf("Possible\n");
    else printf("Impossible\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int M = sc.nextInt();
    
    int[] left;
    left = new int[M];
    int[] right;
    right = new int[M];

    for ( int i = 0 ; i < M ; i++ ){
      left[i] = sc.nextInt();
      right[i] = sc.nextInt();
    }

    int min=0 , max=right[0] ;
    for(int i = 0; i < M; i++) {
      if(min < left[i]) {
          min = left[i];
      }
      if(max > right[i]) {
        max = right[i];
      }
    }

    if(max>N){
      max=N;
    }
    if(max-min+1<0){
      System.out.println(0);
    }else{
      System.out.println(max-min+1);
    }

  }
}

Measured memory_bytes: 63944
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>


int min(int a ,int b){
	if(a<b){
		return a;
	}
	return b;
}



int main(){
	int n,i,power;
	int dp[100003]={};
	scanf("%d",&n);
	for (i = 0; i < 6; i++) {
		dp[i]=i;
	}
	for (i = 1; i < 100002; i++) {
		dp[i]=100000;
		power=1;
		while (power<=i){
			dp[i]=min(dp[i],dp[i-power]+1);
			power*=6;
		}
		power=1;
		while (power<=i){
			dp[i]=min(dp[i],dp[i-power]+1);
			power*=9;
		}
	}
	printf("%d",dp[n]);
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<int> rank_(0);
vector<int> parent(0);

void DisjointSet(int size){
    for(int i=0; i<size; i++){
        rank_.push_back(0);
        parent.push_back(i);
    }
}
    
void makeSet(int x){
    parent[x]=x;
    rank_[x]=0;
}

int findSet(int x){
    if (x!=parent[x]){
        parent[x]=findSet(parent[x]);
    }
    return parent[x];
}

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


void link(int x, int y){
    if (rank_[x] > rank_[y]){
        parent[y]=x;
    }else{
        parent[x]=y;
        if (rank_[x]==rank_[y]){
            rank_[y]+=1;
        }
    }
}

void unite(int x, int y){
    link(findSet(x), findSet(y));
}



int main(){
    int N,M;
    cin >> N >> M;
    
    vector<int> language(M,-1);
  	DisjointSet(N);

    for(int i=0; i<N; i++){
        int K;
        cin >> K;
        for(int j=0; j<K; j++){
            int L;
            cin >> L;
            L--;
            if(language[L]!=-1){
                unite(language[L],i);
            }else{
                language[L]=i;
            }
        }
    }
    string ans="YES";
    for(int i=0; i<N-1; i++){
        if(same(i,i+1))continue;
        else{
            ans="NO";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1660
n=int(input())
a=list(map(int,input().split()))

left=[]
right=[]
if n%2!=0:
    for i in range(0,n,2):
        left.append(a[n-i-1])
    for i in range(1,n,2):
        right.append(a[i])
else:
    for i in range(0,n,2):
        left.append(a[n-i-1])
    for i in range(0,n,2):
        right.append(a[i])


ans=left
ans.extend(right)
L=[str(a) for a in ans]
L=" ".join(L)
print(L)


Measured memory_bytes: 36292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

int main() {
    long long int n, k, ans = 0;
    cin >> n >> k;
    for (auto t = k; n % t != n; t *= k) {
        ans++;
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
//----------------------------------------------------------------
//G-1

#include <iostream>
#include <vector>
using namespace std;

const long long INF = 1LL<<60;

// 入力
int N, M;
vector<vector<int> > G; // グラフ

// メモ化再帰
int dp[100100];
int rec(int v) {
    if (dp[v] != -1) return dp[v]; // 既に更新済み

    int res = 0;
    for (auto nv : G[v]) {
        res = max(res, rec(nv) + 1);
    }
    return dp[v] = res; // メモしながらリターン
}


int main() {
    // 入力受け取り
    cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int x, y; cin >> x >> y;
        --x, --y; // 0-indexed にする
        G[x].push_back(y);
    }

    // 初期化
    for (int v = 0; v < N; ++v) dp[v] = -1;

    // 全ノードを一通り更新しながら答えを求める
    int res = 0;
    for (int v = 0; v < N; ++v) res = max(res, rec(v));
    cout << res << endl;
}

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

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;

	bool flag = true;

	if (s.size() != a + b + 1)
	{
		flag = false;
	}
	if (s.at(a) != '-')
	{
		flag = false;
	}

	for (int i = 0; i < s.size(); i++)
	{
		if (i + 1 != a + 1)
		{
			if (s.at(i) == '-')
			{
				flag = false;
				break;
			}
		}
	}

	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)

int main() {
    int x, y;
    cin >> x >> y;
    char c[x][y];
    rep(i, x) {
        rep(j, y) cin >> c[i][j];
    }

    char a[x+2][y+2];

    rep(i, x+2) {
        rep(j, y+2) {
            if(i == 0 || i == x+1 || j == 0 || j == y+1) {
                a[i][j] = '#';
            }
            else a[i][j] = c[i-1][j-1];
        }
    }

    rep(i, x+2) {
        rep(j, y+2) {
            cout << a[i][j];
            if(j == y+1) cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int
main (void)
{
  double x1, x2, y1, y2, result;
  scanf ("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
  result = sqrt (pow (fabs (x1 - x2), 2.0) + pow (fabs (y1 - y2), 2.0));
  printf ("%lf\n", result);
  return 0;
}

Measured memory_bytes: 652