akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
struct Node;
vector<Node> Va;
vector<Node> Vb;
struct Node {
  vector<int> nbr;
  vector<lint> cost;
  lint d = 1e15;
  bool operator < (const Node &other) const { return d > other.d;}
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--; t--;
  REP(i, n) Va.emplace_back();
  REP(i, n) Vb.emplace_back();
  REP(i, m) {
    lint u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    Va[u].nbr.push_back(v);
    Va[v].nbr.push_back(u);
    Va[u].cost.push_back(a);
    Va[v].cost.push_back(a);
    Vb[u].nbr.push_back(v);
    Vb[v].nbr.push_back(u);
    Vb[u].cost.push_back(b);
    Vb[v].cost.push_back(b);
  }
  priority_queue<Node, vector<Node>> pq;
  Va[s].d = 0;
  pq.push(Va[s]);
  while(!pq.empty()) {
    Node no = pq.top();
    pq.pop();
    REP(i, no.nbr.size()) {
      if(no.d + no.cost[i] < Va[no.nbr[i]].d) {
        Va[no.nbr[i]].d = no.d + no.cost[i];
        pq.push(Va[no.nbr[i]]);
      }
    }
  }
  Vb[t].d = 0;
  pq.push(Vb[t]);
  while(!pq.empty()) {
    Node no = pq.top();
    pq.pop();
    REP(i, no.nbr.size()) {
      if(no.d + no.cost[i] < Vb[no.nbr[i]].d) {
        Vb[no.nbr[i]].d = no.d + no.cost[i];
        pq.push(Vb[no.nbr[i]]);
      }
    }
  }
  lint min = 1e15;
  vector<lint> ans(n);
  IREP(i, n) {
    lint tmp = Va[i].d + Vb[i].d;
    if(tmp < min) min = tmp;
    ans[i] = 1e15 - min;
  }
  REP(i, n) cout << ans[i] << "\n";
  return 0;
}

Measured memory_bytes: 35564
program RainySeason
!variable
      implicit none
      character(len=3) :: S
      integer :: n_rainy
      integer :: n_max
      integer :: i
!read
      read(*,*) S
!
      n_rainy = 0
      n_max = 0
      do i=1,3
        if(S(i:i) == 'R') n_rainy = n_rainy + 1
        if(S(i:i) == 'S') n_rainy = 0
        if(n_max < n_rainy) n_max = n_rainy
      end do
!
      write(*,*) n_max
!
      end program RainySeason

Measured memory_bytes: 2792
N , T = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]

L.sort()
while(len(L) > 0 and L[0][1] > T):
    L.pop(0)
if L.__len__() == 0:
    print("TLE")
else:
    print(L[0][0])


Measured memory_bytes: 2940
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
#define p 924844033
#define md(_o) (((_o)>=p)?((_o)-p):(_o))
using namespace std;
namespace ywy{
	ll dp[2222][2222][2][2],f[2222][2222],jc[2222],jcny[2222],g[2222];
	inline ll mi(int a,int b){
		ll ans=1,tmp=a;while(b){
			if(b&1)ans=(ans*tmp)%p;tmp=(tmp*tmp)%p;b>>=1;
		}return(ans);
	}
	inline ll cnm(int n,int m){
		if(n<m||m<0)return(0);ll cjr=jc[n];cjr*=jcny[m];cjr%=p;cjr*=jcny[n-m];return(cjr%p);
	}
	void ywymain(){
		int n,k;cin>>n>>k;f[0][0]=1;for(register int i=1;i<=k;i++){
			dp[0][0][0][0]=1;int lst=0;for(register int j=1;i+j*k<=n;j++){
				lst=j;for(register int a=0;a<=j;a++){
					if(dp[j-1][a][0][0]){
						dp[j][a+1][0][1]=md(dp[j][a+1][0][1]+dp[j-1][a][0][0]);
						dp[j][a+1][1][0]=md(dp[j][a+1][1][0]+dp[j-1][a][0][0]);
						dp[j][a][0][0]=md(dp[j][a][0][0]+dp[j-1][a][0][0]);
						dp[j][a+2][1][1]=md(dp[j][a+2][1][1]+dp[j-1][a][0][0]);
					}if(dp[j-1][a][0][1]){
						dp[j][a+1][0][1]=md(dp[j][a+1][0][1]+dp[j-1][a][0][1]);
						dp[j][a][0][0]=md(dp[j][a][0][0]+dp[j-1][a][0][1]);
					}if(dp[j-1][a][1][1]){
						dp[j][a][0][0]=md(dp[j][a][0][0]+dp[j-1][a][1][1]);
					}if(dp[j-1][a][1][0]){
						dp[j][a+1][1][0]=md(dp[j][a+1][1][0]+dp[j-1][a][1][0]);
						dp[j][a][0][0]=md(dp[j][a][0][0]+dp[j-1][a][1][0]);
					}
				}
			}
			for(register int j=0;j<=n;j++){
				for(register int a=0;a<=lst+1&&a<=j;a++){
					for(register int b=0;b<=1;b++){
						for(register int c=0;c<=1;c++){
							f[i][j]=(f[i][j]+f[i-1][j-a]*dp[lst][a][b][c])%p;
						}
					}
				}
			}for(register int j=0;j<=lst+1;j++){
				for(register int a=0;a<=lst+1;a++){
					for(register int b=0;b<=1;b++){
						for(register int c=0;c<=1;c++)dp[j][a][b][c]=0;
					}
				}
			}
		}jc[0]=1;for(register int i=1;i<=n;i++)jc[i]=(jc[i-1]*i)%p;jcny[n]=mi(jc[n],p-2);
		ll ans=0;for(register int i=0;i<=n;i++){
			if(i&1)ans=(ans-jc[n-i]*f[k][i])%p;else ans=(ans+jc[n-i]*f[k][i])%p;
		}ans+=p;ans%=p;cout<<ans<<endl;
	}	
}
int main(){
	ywy::ywymain();return(0);
}

Measured memory_bytes: 141568
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int N, M, A;
int dp[10001];
map<int, int> mii;

int main() {
    int c[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
    cin >> N >> M;
    REP(i, M) {
        cin >> A;
        mii[A] = max(mii[A], c[A - 1]);
    }
    dp[0] = 0;

    FOR(i, 1, N + 1) {
        dp[i] = -1;
        for (auto p : mii) {
            if (i - p.second >= 0) {
                dp[i] = max(dp[i], dp[i - p.second] + 1);
            }
        }
    }

    string ans = "";
    int remain = dp[N], match = N;
    while (match > 0) {
        for (auto it = mii.rbegin(); it != mii.rend(); it++) {
            if (match - it->second >= 0 && dp[match - it->second] == remain - 1) {
                ans += to_string(it->first);
                match -= it->second;
                remain--;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
cmd = [[-1,0],[1,0],[0,1],[0,-1]]
H,W = map(int,input().split())
ch,cw = map(int,input().split())
dh,dw = map(int,input().split())
Map = [["#"]*(W+2)]
for _ in range(H):
    Map.append(["#"]+list(input())[:-1] + ["#"])
Map.append(["#"]*(W+2))
Q = deque([[ch,cw]])
Next = deque([])
visidat = [[10**6]*(W+2) for _ in range(H+2)]
num = 0
flag = 0
fl = 0
visidat[ch][cw] = 0
while flag == 0:
    while len(Q) != 0:
        h,w = Q.popleft()
        if h == dh and w == dw:
            print(num)
            flag = 1
            break
        if visidat[h][w] >= num:
            for i in range(-2,3):
                for j in range(-2,3):
                    p,q = h+i,w+j
                    if p < 0 or q < 0 or p > H+1 or q > W+1 or ((abs(i)+abs(j))<=1):
                        continue
                    if Map[p][q] == ".":
                        if visidat[p][q] > num + 1:
                            Next.append([p,q])
                            visidat[p][q] = num + 1
            for cx,cy in cmd:
                newh = cy + h
                neww = cx + w
                if Map[newh][neww] == "#":
                    continue
                else:
                    if visidat[newh][neww] > num :
                        visidat[newh][neww] = num
                        Q.append([newh,neww])
        else:
            continue
        
    Q = Next
    if len(Q) == 0:
        if flag == 0:
            fl = 1
        break
    Next = deque([])
    num += 1
if fl == 1:
    print(-1)


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

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> v(m);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        v.at(i) = make_pair(a, b);
    }
    sort(v.begin(), v.end(), compare_by_b);

    int ans = 0;
    ll cur = -1e+10;

    rep(i,m){
        if (cur > v.at(i).first) continue;
        ans ++;
        cur = v.at(i).second;
    }
    cout << ans << endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int r;
    cin >>r;
    
    if(r < 1200)
    {
        cout << "ABC" << endl;
    }
    else if ( r >= 1200 && r < 2800)
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "AGC" << endl;
    }
}


Measured memory_bytes: 3596
def K(n):
  a=0
  while n>0:
    n=n//10
    a=a+1
  return a

n,m=map(int,input().split())
A=[[0]*3 for i in range(m)]
ans=[0]*m
for i in range(m):
  A[i][0],A[i][1]=map(int,input().split())
  A[i][2]=i
A.sort()
a=0
b=1
for i in range(m):
  if a==A[i][0]:
    b=b+1
  else:
    a=A[i][0]
    b=1
  S=""
  T=""
  B=list(str(A[i][0]))
  C=list(str(b))
  for j in range(6-K(A[i][0])):
    S=S+"0"
  for j in range(K(A[i][0])):
    S=S+B[j]
  for j in range(6-K(b)):
    T=T+"0"
  for j in range(K(b)):
    T=T+C[j]
  ans[A[i][2]]=S+T
for i in range(m):
  print(ans[i])

Measured memory_bytes: 31328
import           Control.Monad

-- bitter-alchemy.hs --- Bitter Alchemy

-- author: Seong Yong-ju <sei40kr@gmail.com>

solve :: Int -> Int -> [Int] -> Int
solve n x ms = n + quot (x - sum ms) (minimum ms)

main :: IO ()
main = do
  [n, x] <- map (read :: String -> Int) . words <$> getLine
  ms <- replicateM n $ (read :: String -> Int) <$> getLine
  print $ solve n x ms


Measured memory_bytes: 892
#!/usr/bin/env python3
import sys
import math

MOD = 1000000007  # type: int

def c(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = MOD #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


def solve(N: int, K: int):
    for i in range(1,K+1):
        print((c(K-1, i-1) * c(N-K+1, i)) % MOD)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 4584
#include <bits/stdc++.h>
using namespace std;
int N, a[3005];
int main(){
	long long ans = 0;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++){
		scanf("%d", a + i);
		ans += a[i] - 1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const ull MOD = 998244353;
const int MSIZE = 100007;
const double Pi = 3.14159265358979323146;

int main(){
  int n;  cin >> n;
  ll ans = 1;
  REP(i, n){
    ll a; cin >> a;
    if(a==0){ans=0;}
    if(ans == -1){continue;}
    if(a!=0 && LLINF/a < ans){ans=-1;}
    else{ans *= a;}
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
  		
      	int nums[] = new int[3];
      	boolean por = false;
      	
      	for(int i=0; i < 3;i++) nums[i] = sc.nextInt();
      	Arrays.sort(nums);
      
      	if(nums[0] == nums[1]){
        	if(nums[0] != nums[2]) por = true;
        } else if(nums[1] == nums[2]){
        	if(nums[1] != nums[0]) por = true;
        }
      
      	if(por) System.out.println("Yes");
      	else System.out.println("No");
	}
}


Measured memory_bytes: 35420
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>

//using namespace __gnu_pbds;
using namespace std;

#define sz(x)                 x.size()
#define all(x)                x.begin(), x.end()
#define tr(x, it)             for(auto it = x.begin();it != x.end();it++)
#define fo(i, k, n)           for(int i = k;i < n;i++)
#define Fo(i, k, n)           for(int i = k;i >= n;i--)
#define el                    "\n"
#define ff                    first
#define ss                    second
#define ll                    long long
#define pb                    push_back
#define mp                    make_pair
#define pii                   pair<int, int>
#define vi                    vector<int>
#define mii                   map<int, int>
//#define pqb                   priority_queue<int>
//#define pqs                   priority_queue<int, vi, greater<int>>
//#define pc(x)                 putchar(x);
//#define setbits(x)            __builtin_popcountll(x)
//#define zrobits(x)            __builtin_ctzll(x)
#define mod                   1000000007
#define inf                   1e18
#define deb(x)                cout<<#x<< " = "<< x<<"\n";
//#define ps(x, y)              fixed<<setprecision(y)<<x
//#define mk(arr, n, type)      type *arr = new type[n];
//#define w(x)                  int x; cin>>x; while(x--)

void solve(){
	int l, r, d;
	cin>>l>>r>>d;
	int ans = 0;
	fo(i, l, r+1){
		if(i%d == 0){
			ans++;
		}
	}
	cout<<ans;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
		cout<<el;
	}
	return 0;
}


Measured memory_bytes: 3632
#ABC 116, B - collatz problem
import itertools
def f(x):
    if x % 2 == 0:
        return x / 2
    else:
        return 3*x + 1

s = int(input())
A = []
A.append(s)
for i in itertools.count(1):
    A.append(f(A[i-1]))
    if A[i] in A[:-1]:
        print(i+1)
        break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = max(a * d, b * d);
    ans = max(ans, b * c);
    ans = max(ans, a * c);
    cout << ans << endl;
    return 0;
}

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

using Weight = int;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src_, int dst_, Weight weight_) :
        src(src_), dst(dst_), weight(weight_) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

vector<int> tarjanScc(const Graph &g){
    int n = g.size(), idx = 0, k = 0, s = 0;
    vector<int> index(n, -1), lowlink(n), onStack(n), cmp(n), stk(n);
    function<void(int)> strongconnect;
    strongconnect = [&](int v){
        index[v] = lowlink[v] = idx++;
        stk[s++] = v; onStack[v] = true;
        for(auto &e : g[v]){
            int w = e.dst;
            if(index[w] == -1){
                strongconnect(w);
                lowlink[v] = min(lowlink[v], lowlink[w]);
            } else if(onStack[w]){
                lowlink[v] = min(lowlink[v], index[w]);
            }
        }
        if(lowlink[v] == index[v]){
            int w;
            do {
                w = stk[--s]; onStack[w] = false; cmp[w] = k;
            } while(w != v);
            ++k;
        }
    };
    for(int v = 0; v < n; v++) if(index[v] == -1) strongconnect(v);
    return cmp;
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n,m;
    cin >> n >> m;
    Graph g(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        g[a].emplace_back(a,b,0);
    }
    vector<int> c = tarjanScc(g);
    int q; cin >> q;
    rep(i,q){
        int a,b;
        cin >> a >> b;
        cout << (c[a] == c[b]) << '\n';
    }
}

Measured memory_bytes: 4516
#include<stdio.h>
int main(void)
{
	int A,B,a,b,ov,L;

	while(scanf("%d %d",&A,&B)!=EOF){
		if(a>b){
			a=A;
			b=B;
		}
		else{
			a=B;
			b=A;
		}
		while((ov=a%b)!=0){
			a=b;
			b=ov;
		}
		L=A*(B/b);
		printf("%d %d\n",b,L);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 666666;
int n,q,a[N],l[N],buc[N],res;
void add(int x, int v){
	if(v==1){l[x]--;if(l[x]>=1){res+=!buc[l[x]];buc[l[x]]++;}}
	else{if(l[x]>=1){buc[l[x]]--;res-=!buc[l[x]];}l[x]++;}
}
int main() {
	read(n);read(q);rep(i,1,n)l[i]=i+1;
	rep(i,1,n)read(a[i]),add(a[i],1);
	while(q--){
		int x,y;read(x);read(y);add(a[x],-1);a[x]=y;add(a[x],1);
		printf("%d\n",n-res);
	}
	return 0;
}


Measured memory_bytes: 6400
#include <stdio.h>
#include <string.h>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);

    if(a==5){
        if(b==7){
            if(c==5){
                printf("YES");
            }else{
                printf("NO\n");
            }
        }else if(c==7){
            if(b==5){
                printf("YES\n");
            }else{
                printf("NO\n");
            }
        }else{
            printf("NO\n");
        }
    }else if(a==7){
        if(b==5){
            if(c==5){
                printf("YES");
            }
        }else{
            printf("NO");
        }
    }else{
        printf("NO\n");
    }

    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <list>
#include <numeric>
#include <math.h>
#include <cstdlib>
#include <queue>
#include <iterator>
#include <limits>
#include <string>
#include <sstream>
#include <iomanip>
#include <bitset>
#include <mutex>
#include <condition_variable>
#include <atomic>
#include <stack>
#include <memory>
#include <deque>
#include <string_view>
#include <random>
#include <chrono>
#include <cstring>

using namespace std;

static int my_speed_up = []() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }();
using ll = long long; using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T> using vv = vector<vector<T>>;
template<class T> using vvv = vector<vector<vector<T>>>;
template<class T> using vvvv = vector<vector<vector<vector<T>>>>;
#define for_b(i, b) for (int i = 0; i < (b); ++i)
#define for_ab(i, a, b) for (int i = a; i < (b); ++i)
#define what_is(x) cout << #x << " = " << x << endl;
#define what_are(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl;
#define pad(x) for_b(i, x) cout << "  ";
#define show_1d(___x) cout << #___x << " = "; for (auto& ___num : ___x) cout << ___num << ", "; cout << endl;
#define show_2d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto ___num : ___row) cout << ___num << ", "; cout << endl; }
#define show_3d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto& ___row2 : ___row) { for (auto ___num : ___row2) cout << ___num << ", "; cout << endl; }cout << endl; }


int main()
{
    int n, d_in;
    cin >> n >> d_in;
    
    ll d = (ll)d_in * (ll)d_in;
    
    int res = 0;
    for_b(i,n)
    {
        ll x, y;
        cin >> x >> y;
        
        ll dis = x*x + y*y;
        if (dis <= d) ++res;
    }
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N;
	cin >> N;
	int ans = 1;
	int b;
	cin >> b;
	int i = 1;
	while (i < N)
	{
		int tmp;
		cin >> tmp;
		i++;
		if (tmp != b)
		{
			if (tmp > b)
			{
				b = tmp;
				for (int j = i; j < N; j++)
				{
					cin >> tmp;
					i++;
					if (tmp < b)
					{
						ans++;
						b = tmp;
						break ;
					}
					b = tmp;
				}
			}
			else
			{
				b = tmp;
				for (int j = i; j < N; j++)
				{
					cin >> tmp;
					i++;
					if (tmp > b)
					{
						ans++;
						b = tmp;
						break ;
					}
					b = tmp;
				}
			}
		}
	}
	cout << ans <<endl;
}



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

const int N = 1e5 + 5;

const int maxn = 1e3+5;
const long long  INF = 1e18;

struct Edge {
    int from, to, dist;
    Edge(int u, int v, int d):from(u),to(v),dist(d) {}
};

struct Bellman_ford {
    int n, m;
    vector<Edge> edges;
    vector<int> G[maxn];
    bool inq[maxn];
    bool neg[maxn];//点的路径上是否有负环
    long long d[maxn];//s到各个点的距离
    int p[maxn];//最短路中的上一条弧
    int cnt[maxn]; //点进队列次数
    
    
    void init(int n) {
        this->n = n;
        for(int i = 0; i < n; i++) G[i].clear();
        edges.clear();
    }
    
    void AddEdge(int from, int to, int dist) {
        edges.push_back(Edge(from, to, dist));
        m = edges.size();
        G[from].push_back(m-1);
    }
    
    
    //只能判断是否含环，不能判断到某点的路径上是否含环。
    bool bellman_ford_que(int s) {
        queue<int> Q;
        memset(inq, 0, sizeof(inq));
        memset(cnt, 0, sizeof(cnt));
        for(int i = 0; i < n; i++) d[i] = INF;
        d[s] = 0;
        inq[s] = true;  //标记是否在队列中
        Q.push(s);
        while(!Q.empty()) { //松弛到不能松弛为止
            int u = Q.front(); Q.pop();
            inq[u] = false;
            for(int i = 0; i < G[u].size(); i++) {
                Edge& e = edges[G[u][i]];
                if(d[u] < INF && d[e.to] > d[u] + e.dist) {
                    d[e.to] = d[u] + e.dist;
                    p[e.to] = G[u][i];
                    if(!inq[e.to]) {
                        Q.push(e.to);
                        inq[e.to] = true;
                        if(++cnt[e.to] > n) return false;
                    }
                }
            }
        }
        return true;
    }
    
    void bellman_ford(int s) {
        for(int i = 0; i < n; i++) d[i] = INF;
        d[s] = 0;
        //如果不含环，最短路最多经过n-1个点（不包括起点）， 松弛n-1次即可
        for (int k = 0; k < n-1; k++){
            for (int i = 0; i < m; i++){
                int x = edges[i].from;
                int y = edges[i].to;
                if(d[x]<INF) d[y] = min(d[y], d[x] + edges[i].dist);
            }
        }
        
        for (int k = 0; k < n-1; k++){
            for (int i = 0; i < m; i++){
                int x = edges[i].from;
                int y = edges[i].to;
                if(d[x]<INF && d[y] > d[x] + edges[i].dist) {
                    d[y] = d[x] + edges[i].dist;
                    neg[y] = true;
                }
                if(neg[x])neg[y] = true;
            }
        }
    }
};

Bellman_ford g;

void solve(){
    int n,m;
    cin>>n>>m;
    g.init(n); //n为顶点数
    int x,y,c;
    for (int i = 1; i <= m; i++){
        cin>>x>>y>>c;
        x--, y--;  //顶点是从0开始编号
        g.AddEdge(x, y, -c);
    }
    g.bellman_ford(0);
    if(!g.neg[n-1]) cout<<-g.d[n-1]<<endl;
    else cout<<"inf"<<endl;
}

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    solve();
    
    
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 256;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int dp[MAX/2][MAX][MAX/2];
int ns[MAX/2];

void solve(void){
    int N, K;
    cin >> N >> K;
    rep(N, i) scanf("%d\n", &ns[i]);

    dp[0][0][0] = 1LL;
    rep(N, i) rep(MAX, j) rep(N, k) {
        dp[i+1][j][k] += dp[i][j][k];
        dp[i+1][j][k] %= MOD;
        dp[i+1][j^(ns[i])][k+1] += dp[i][j][k];
        dp[i+1][j^(ns[i])][k+1] %= MOD;
    }
    ll ans = 0LL;
    rep(N+1, k) {
        ll kaijyo = 1LL;
        Rep(1, k, i) {
            kaijyo *= (ll)i;
            kaijyo %= MOD;
        }
        ans += dp[N][K][k] * kaijyo;
        ans %= MOD;
    }
    
    cout << ans << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 14464
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

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

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

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

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


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

    N = ii()
    H = il()

    dp = [0]*N
    dp[1] = abs(H[0]-H[1])
    for n in range(2, N):
        dp[n] = min(abs(H[n-2]-H[n])+dp[n-2], abs(H[n-1]-H[n])+dp[n-1])
    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 13072
#include<stdio.h>

void maxHeapify(int);

int n, A[500005];

int main(){
  int i;

  scanf("%d",&n);

  for(i = 1 ; i <= n ; i++){
    scanf("%d",&A[i]);
  }
  for(i = n / 2 ; i >= 1 ; i--) maxHeapify(i);

  for(i = 1 ; i <= n ; i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}

void maxHeapify(int z){
  int right, left, largest;
  int tmp;
  left = 2 * z;
  right = 2 * z + 1;

  if(left <= n && A[left] > A [z]) largest = left;
  else largest = z;

  if(right <= n && A[right] > A[largest]) largest = right;

  if(largest != z){
    tmp = A[z];
    A[z] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}



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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

string s, t;
int ans = 1001;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> s >> t;
	for (int i = 0; i <= sz(s) - sz(t); ++i) {
		int tmp = 0;
		for (int j = 0; j < sz(t); ++j) {
			if (t[j] != s[j + i]) ++tmp;
		}
		
		ans = min(tmp, ans);
	}
	
	cout << ans;
}


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

int main(int argc, char* argv[]){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if((abs(a-c) <= d) || (abs(a-b) <= d && abs(b-c) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define nl cout<<"\n"
#define db(x) cout<<x<<" "
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define fk(a,b) for(int k=a;k<b;k++)
#define F first
#define S second
#define UM unordered_map<int,int>
#define MP map<int,int>
#define mxsize (int)1e6
void fun(){
    int n;
    cin>>n;
    int a[n];
    fi(0,n){
        cin>>a[i];
    }
    ll ans=0;
    fi(1,n){
        if(a[i]<a[i-1]){
            ans+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<ans<<"\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("/ATOM/input.txt", "r", stdin);
        freopen("/ATOM/output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    while(t--){
        fun();
    }
}

Measured memory_bytes: 4404
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int selection_sort(vector<int>& as) {
    int ret = 0;
    for (int i = 0; i < as.size(); i++) {
        int min_idx = i;
        for (int j = i; j < as.size(); j++) {
            if (as[j] < as[min_idx]) {
                min_idx = j;
            }
        }
        if (min_idx != i) {
            swap(as[min_idx], as[i]);
            ret++;
        }
    }
    return ret;
}

void print_all(vector<int>& as) {
    for (int i = 0; i < as.size(); i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << as[i];
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> as(n);
    for (auto& a : as) {
        cin >> a;
    }

    int swap_count = selection_sort(as);
    print_all(as);
    cout << swap_count << endl;
}

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

int main() {
	// your code goes here
	int i, j, k=0, n;
	cin>>n;
	for(i=1; i<=n; ++i) {
		cin>>j;
		k+=(j%2);
	}
	if(k%2)	cout<<"NO\n";
	else	cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	bool flag=false;
	for(int i=0;i<a;i++){
		int k;
		cin>>k;
		if(k%2==0&&(k%3!=0&&k%5!=0))
			flag=true;
	}
	if(flag==true)
		cout<<"DENIED";
	else
		cout<<"APPROVED";
	return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m,x = na()
c = []

for i in range(n):
    cc = na()
    c.append(cc)

ans = 1000000000000

for i in range(2 ** n):
    ss = [0]*(m+1)
    for j in range(n):
        if ((i >> j) & 1):
            for k in range(m+1):
                ss[k] += c[j][k]
    for j in range(1,m+1):
        if ss[j] < x:
            break
    else:
        ans = min(ans,ss[0])

if ans == 1000000000000:
    print(-1)
    exit()

print(ans)

Measured memory_bytes: 9244
N = int(input())
S = input()

single_flag = [False]*10
dual_flag = {}
ans = {}
for i in range(10):
    for j in range(10):
        dual_flag[(i, j)] = False
        ans[(i, j)] = set()

for s in S:
    for i in range(10):
        for j in range(10):
            if dual_flag[i, j]:
                ans[(i, j)].add(int(s))
    for i in range(10):
        if single_flag[i]:
            dual_flag[(i, int(s))] = True
    single_flag[int(s)] = True

tmp = 0
for v in ans.values():
    tmp += len(v)
print(tmp)


Measured memory_bytes: 3064
using System;
class Program
{
    static int Main(string[] args)
    {
        switch (Console.ReadLine())
        {
            case "A":
                Console.WriteLine("T");
                break;
            case "T":
                Console.WriteLine("A");
                break;
            case "C":
                Console.WriteLine("G");
                break;
            case "G":
                Console.WriteLine("C");
                break;
        }
        return 0;
    }
}

Measured memory_bytes: 11092
//30/05/2020
/*A step of a tortoise in search of happiness and true act of goodwill.!*/
#include<bits/stdc++.h>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll x,y;
};
struct cmp1{
    bool operator()(const Node &a,const Node &b)const{
        if(a.x==b.x) return a.y<b.y;
        else return a.x>b.x;
    }
};

//Algos
template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//Number Theory
class NumberTheory{
public:
    ll n;
    bool chk[99999995];
    ll GetMod(ll x,ll m);
    ll BigMod (ll b,ll p,ll m){if (p == 0) return 1;if (p%2 == 0){ll s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
    ll ModInv (ll b,ll m){return BigMod(b,m-2,m);}
    ll gcd(ll a,ll b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
    ll lcm(ll a,ll b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
    void sieve(ll x);
    bool IsPrime(ll x);
    bool IsPrime1(ll x){return !chk[x];}
};

/*Containers*/
vector<ll>v;
deque<ll>dq;
stack<ll>stk;
map<ll,ll>mp;
unordered_map<ll,ll>ump;
set<ll>st;
multiset<ll>mst;
unordered_set<ll>ust;
unordered_multiset<ll>umst;
priority_queue<ll,deque<ll>,greater<ll>>pq;
set<Node,cmp1>st1;
map<Node,ll,cmp1>mp1;
priority_queue<Node,deque<Node>,cmp1>pq1;
Pbds<ll>ost;


int main(){
    _fastio
    ll h1,h2,m1,m2;
    ll k;
    cin>>h1>>m1>>h2>>m2>>k;

    ll d=abs(h2-h1);
    if(h1<=h2){
        d*=60;
        d-=m1;
        d+=m2;
    }
    else{
        d=24-d;
        d*=60;
        d-=m1;
        d+=m2;
    }
    d-=k;
    cout<<d<<en;



    return 0;
}

void NumberTheory::sieve(ll x){
    for(ll i=2;i*i<=x;){
        if(chk[i]==0){
            for(ll j=i*i;j<=x;j+=i){
                chk[j]=1;
            }
        }
        if(i==2) i++;
        else i+=2;
    }
}
bool NumberTheory::IsPrime(ll x){
    bool f=true;
    for(ll i=2;i*i<=x;i++){
        if(!x%i){
            f=false;break;
        }
    }
}
ll GetMod(ll x,ll m){
    if(x>=0) return x%m;
    else{
        ll y=abs(x)/m;x+=(y*m+m+m);
        return x%m;
    }
}


Measured memory_bytes: 3648
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func init() {
	// 100MB
	bufsize := 100 * 1024 * 1024
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
	sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
	s := readStringArray(n)
	a := make([]int, n)
	for i := range a {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}
	return a
}
func max(ns ...int) int {
	max := ns[0]
	for _, n := range ns {
		if n > max {
			max = n
		}
	}
	return max
}
func min(ns ...int) int {
	min := ns[0]
	for _, n := range ns {
		if n < min {
			min = n
		}
	}
	return min
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	S := readString()
	var t string
	for range S {
		t += "x"
	}
	fmt.Println(t)
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    string s;cin>>s;
    bool a=true;
    rep(i,(s.size()-1)/2){
        if(s[i]!=s[s.size()-1-i]){
            a=false;
            break;
        }
    }
    rep(i,(s.size()-1)/2){
        if(s[i]!=s[(s.size()-1)/2-1-i]){
            a=false;
            break;
        }
    }
    for(int i=(s.size()+3)/2-1;i<s.size();++i){
        if(s[i]!=s[s.size()-1-i]){
            a=false;
            break;
        }
    }
    if(a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

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

#define DBG
#undef DBG

constexpr int N_MAX = 100000;

int n, m;
vector<int> graph[N_MAX];
int color[N_MAX];

void dfs(int i, int c)
{
    color[i] = c;

    for(int j : graph[i]) {
        if(color[j]) continue;

        dfs(j, c);
    }
}

void solve()
{
    int c = 1;

    REP(i, n) {
        if(color[i]) continue;

        dfs(i, c);
        ++c;
    }
}

int main()
{
    cin >> n >> m;
#ifdef DBG
    cout << n << " " << m << "\n";
#endif

    REP(_, m) {
        int s, t;
        cin >> s >> t;
        graph[s].push_back(t);
        graph[t].push_back(s);
#ifdef DBG
        cout << s << " " << t << "\n";
#endif
    }

    solve();

    int q;
    cin >> q;
#ifdef DBG
    cout << q << "\n";
#endif

    REP(_, q) {
        int s, t;
        cin >> s >> t;
#ifdef DBG
        cout << s << " " << t << "\n";
#endif
        bool conn = color[s] == color[t];
        cout << (conn ? "yes" : "no") << "\n";
    }

    return 0;
}

Measured memory_bytes: 12044
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int grid[1010][1010];
int dp[1010][1010];
int nGrid[1010][1010];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W, N;
  while (true)
  {
    for (int i = 0; i < H; i++)
    {
      for (int j = 0; j < W; j++)
      {
        grid[i][j] = 0;
      }
    }
    for (int i = 0; i < H + 1; i++)
    {
      for (int j = 0; j < W + 1; j++)
      {
        dp[i][j] = 0;
      }
    }
    for (int i = 0; i < H; i++)
    {
      for (int j = 0; j < W; j++)
      {
        nGrid[i][j] = 0;
      }
    }
    
    cin >> H >> W >> N;
    if (H == W && W == N)
      break;

    for (int i = 0; i < H; i++)
    {
      for (int j = 0; j < W; j++)
      {
        cin >> grid[i][j];
      }
    }

    dp[0][0] = N - 1;

    for (int i = 0; i < H; i++)
    {
      for (int j = 0; j < W; j++)
      {
        if (grid[i][j])
        {
          dp[i + 1][j] += dp[i][j] / 2;
          dp[i][j + 1] += (dp[i][j] + 1) / 2;
        }
        else
        {
          dp[i + 1][j] += (dp[i][j] + 1) / 2;
          dp[i][j + 1] += dp[i][j] / 2;
        }
      }
    }

    for (int i = 0; i < H; i++)
    {
      for (int j = 0; j < W; j++)
      {
        if (grid[i][j])
        {
          if (dp[i][j] % 2 == 0)
          {
            nGrid[i][j] = 1;
          }
          else
          {
            nGrid[i][j] = 0;
          }
        }
        else
        {
          if (dp[i][j] % 2 == 0)
          {
            nGrid[i][j] = 0;
          }
          else
          {
            nGrid[i][j] = 1;
          }
        }
      }
    }

    int nowy = 0, nowx = 0;
    while (0 <= nowy && nowy < H && 0 <= nowx && nowx < W)
    {
      if (nGrid[nowy][nowx])
        nowx++;
      else
        nowy++;
    }

    cout << nowy + 1 << " " << nowx + 1 << endl;
  }
  return 0;
}

// N回目の「南」「東」を決めなければならない
// 1～(N - 1)回目にたどりついた場所を知る必要はない．　また詳しいルートを1回ずつ区別して計算する必要もない．なぜならばN回目のルートやたどりつく場所に影響を与えないからであり各交差点を1～(N- 1)回目で何回通ったかが重要になる．まず，交差点(1, 1)をN-1回通る．この後，(1, 1)が東ならば(1, 2)を切り上げの(N - 1)/2回，南ならば(N - 1)/2回通る．同様に(1, 1)が東ならば(2, 1)を(N- 1)/2回，南ならば切上げの(N - 1)/2回通る．整理すると，
// (y, x)をT回通る時，
// (y, x)が東ならば(y, x + 1)を切り上げのT / 2回，(y + 1, x)をT / 2回通る．(y, x)が南ならば(y, x + 1)をT / 2回，(y + 1, x)を切り上げのT / 2回通る．



Measured memory_bytes: 14948
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long  
#define ulli unsigned long long

#define pn           printf("\n")
#define nl           cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define mod     1000000007
#define Inf     1000000000000000
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

bool visited[MX1+1];

int main()
{
    opt;
    
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli N,i;
    cin>>N;
    
    vlli V(N+1);
    rep(i,1,N+1)
    {
        cin>>V[i];
    }
    
    I flag=0,cnt=0;
    i=1;
    
    while(!visited[i])
    {
        visited[i]=1;
        
        if(i==2)
        {
            flag=1;
            break;
        }
        
        i=V[i];
        cnt++;
    }
    
    if(flag)
    {
        cout<<cnt;
    }
    else
    {
        cout<<-1;
    }
    
    
    
    
    
    
    
 return 0;
}


Measured memory_bytes: 1152
n, s = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
M = 998244353

def pow(x, n)
    n == 0 ? 1 : (n.odd? ? x : 1) * pow(x ** 2 % M, n / 2) % M
end

b = Array.new(n+1, 1)
n.times {|i| b[i+1] = b[i] * 2 % M}
rb = pow(2, M - 2)

dp = Array.new(s, 0)
dp[0] = b[n]

ans = 0
a.each do |i|
    break if i > s
    ans = (ans + dp[s - i] * rb) % M

    (s - i - 1).downto(0) do |j|
        dp[i + j] += dp[j] * rb % M
    end
    #p dp
end

p ans

Measured memory_bytes: 14528