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

using namespace std;

typedef long long int ll;

struct coordinate{
    
    int x , y;
    
};

typedef struct coordinate pp;

bool cmpfunc(pp a,pp b){
    
    if(a.x!=b.x) return a.x<b.x;
    
    else return a.y<b.y;
    
}

int main() {
    
    int h , w , m , ansrow , anscol ;
    
    cin >> h >> w >> m;
     
    int row[h+1] , col[w+1];
    
    for(int i=1 ; i<=h ;i++ ) row[i]=0;
    
    for(int i=1 ; i<=w ;i++ ) col[i]=0;
    
    pp point[m] ;
    
    for(int i=0;i<m;i++)
    {
        cin>>point[i].x>>point[i].y;
        
        row[point[i].x]++,col[point[i].y]++;
    }
    
    sort(point,point+m,cmpfunc);
    
    /*for(int i=0;i<m;i++) cout<<point[i].x<<" "<<point[i].y<<endl;*/
    
    int index1=-1 , index2=-1 , rowqueue[300005] , colqueue[300005] , t=0 , flag=1 , note[w+1];
    
    for(int i=1;i<=h;i++)
    {
        if(row[i]>t) t=row[i] ; 
    }
    
    for(int i=1;i<=h;i++)
    {
        if(row[i]==t) rowqueue[++index1] = i ;
    }
    
    t=0;
    
    for(int i=1;i<=w;i++) 
    {
        if(col[i]>t) t=col[i] ;
    }
    
    for(int i=1 ; i<=w ; i++) 
    {
        if(col[i]==t) colqueue[++index2] = i;
    }
    
    ansrow = rowqueue[0] , anscol = colqueue[0] ;
    
    int i = 0 , j = 0 , k , z;
    
    for(k=1;k<=w;k++) note[k]=0;
    
    while(i<m)
    {
        if((point[i].x==rowqueue[j])&(j<=index1)) { 
            
            z=point[i].x;
            
            for( ; point[i].x==z ; i++ ) note[point[i].y]++; 
        }
        
        else if((point[i].x>rowqueue[j])&(j<=index1)) j++ ;
        
        else i++ ;
    
    }
    
    for(i=0;i<=index2;i++)
    {
        if(note[colqueue[i]]<index1+1) flag=0 ;
    }
    
    int ans = col[anscol] + row[ansrow] ;
    
    if(flag) ans-- ;
    
    cout<<ans;
}


Measured memory_bytes: 11804
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod = 1e9+7;
//LLONG_MIN

//AC

int main(void){
	bool ok=false;
	string s,t;
	cin>>s>>t;
	rep(i,s.size()){//始点
		bool can=true;
		rep(j,s.size()){
			if(s[(i+j)%s.size()]!=t[j])can=false;
		}
		if(can)ok=true;
	}
	if(ok){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
# E - NEQ

N, M = map(int, input().split())
MOD = 10 ** 9 + 7

fac = [1, 1]
inv = [0, 1]
finv = [1, 1]

for i in range(2, M+1):
    fac.append(fac[-1] * i % MOD)
    inv.append(MOD - inv[MOD%i] * (MOD//i) % MOD)
    finv.append(finv[-1] * inv[-1] % MOD)

fixed = (fac[N] * fac[M] * pow(finv[M-N], 2, MOD)) % MOD

def f(k):
    return (fac[M-k] * finv[k] * finv[N-k]) % MOD

ans = 0
for i in range(N+1):
    ans = (ans + f(i) * pow(-1, i)) % MOD

print((fixed * ans) % MOD)

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

int main()
{
	int n,d;
	cin>>n>>d;
	int a[n][d];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
		{
			cin>>a[i][j]; 
		}
	 } 
	 int ans=0;
	 for(int i=0;i<n-1;i++)
	 {
	 	for(int j=i+1;j<n;j++)
	 	{
	 		int sum=0;
	 		for(int k=0;k<d;k++)
			 {
			 	sum+=fabs(a[i][k]-a[j][k])*fabs(a[i][k]-a[j][k]);
			  } 
			  if(sqrt(sum)==int(sqrt(sum)))
			  {
			  	ans++;
			  }
		 }
	 }
	 cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
    long i, j, N;
    cin >> N;
    long dp[N+1];
    for(i=0; i<=N; i++){
        dp[i] = i; 
    }
    for(i=1; i<=N; i++){
        for(j=6; j<=i; j*=6){
            dp[i] = min(dp[i], dp[i-j]+1);
        }
        for(j=9; j<=i; j*=9){
            dp[i] = min(dp[i], dp[i-j]+1);
        }
    }
    cout << dp[N] <<'\n';
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
 
int main(){
  long long a, b, k;
  
  cin >> a >> b >> k;
  
  if (k <= a) {
  	a -= k;
  }
  else if (k <= a + b) {
    b -= k - a;
    a = 0;
  }
  else {
    a = 0;
    b = 0;
  }
  
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    private static final int MOD = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] H = new int[N];
        for (int i = 0; i < N; i++) {
            H[i] = sc.nextInt();
        }

        Arrays.sort(H);
        long ans = 0;
        for (int i = 0; i < N-K; i++) {
            ans += H[i];
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 65256
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>

using namespace std;
#define int long long
constexpr int mod = 1000000007;

#define LOADVECTOR(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


int daikei(int n, int x) {
	if (2 * x == n) {
		return n;
	}
	int k = x / (n - x);
	if (2 <= k)return 2 * (k - 1)*(n - x) + daikei(n - (k - 1) * (n - x), x - (k - 1) * (n - x));
	if (2 * x >= n) {
		return 2 * (n - x) + daikei(x, 2 * x - n);
	}
	else {
		return n + daikei(n - x, n - 2 * x);
	}
}

signed main() {
	ios::sync_with_stdio(false);
	LOAD(int, N);
	LOAD(int, X);

	cout << X + daikei(N, X) << endl;
	return 0;
}
#endif


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

    using namespace std;
     
    int main(){
    	char s [4];
    	char t [4];
    	int cnt = 0;
    	scanf("%s", s);
    	scanf("%s", t);
    	for (int i = 0; i < 3; ++i){
    		if(s[i]==t[i]) cnt++;
    	}
    	printf("%d",cnt);
    	return 0;
    }

Measured memory_bytes: 256
#include <stdio.h>


int main()
{
  int i, y, y1;
  long long x1, x2, x3;
  long long h, w, min, max, answer;

  scanf("%lld %lld", &h, &w);
  answer = h * w;
  if(h % 3 == 0 || w % 3 == 0)
  {
    printf("0");
  }
  else
  {
    //1
    for(i=0; i<=h; i++)
    {
      //
      x1 = i * w;
      x2 = (h - i) * (w / 2);
      x3 = h * w - x1 -x2;

      max = x1;
      if(max < x2) max = x2;
      if(max < x3) max = x3;

      min = x1;
      if(min > x2) min = x2;
      if(min > x3) min = x3;

      if(answer > max - min) answer = max - min;

      //
      y1 = (h - i) / 2;
      x2 = y1 * w;
      x3 = h * w - x1 -x2;

      max = x1;
      if(max < x2) max = x2;
      if(max < x3) max = x3;

      min = x1;
      if(min > x2) min = x2;
      if(min > x3) min = x3;

      if(answer > max - min) answer = max - min;
    }

    //2
    y = h;
    h = w;
    w = y;
    for(i=0; i<=h; i++)
    {
      //
      x1 = i * w;
      x2 = (h - i) * (w / 2);
      x3 = h * w - x1 -x2;
      max = x1;
      if(max < x2) max = x2;
      if(max < x3) max = x3;

      min = x1;
      if(min > x2) min = x2;
      if(min > x3) min = x3;

      if(answer > max - min) answer = max - min;

      //
      y1 = (h - i) / 2;
      x2 = y1 * w;
      x3 = h * w - x1 -x2;
      max = x1;
      if(max < x2) max = x2;
      if(max < x3) max = x3;

      min = x1;
      if(min > x2) min = x2;
      if(min > x3) min = x3;

      if(answer > max - min) answer = max - min;

    }
    printf("%lld", answer);
  }
  return 0;
}


Measured memory_bytes: 128
class Puzzle():
  def __init__(self, mat, N):
    self.mat = mat
    self.h = N
    self.score = 0

  def calc(self):
    tmp_score = self.score

    for i in range(self.h):
      for j in range(3):
        if self.mat[i][j] > 0:
          # 5,2
          for k in range(5, 2, -1):
            if j+k <= 7 and k-j >= 3:
              s = set(self.mat[i][j:k])
              if len(s) == 1 and -1 not in s:
                tmp_score += list(s)[0] * (k-j)
                for l in range(j, k):
                  self.mat[i][l] = -1
                break

    if self.score >= tmp_score:
      return False
    else:
      self.score = tmp_score
      return True

  def flatten(self):
    pivot_mat = []
    for i in range(5):
      row = []
      for j in range(self.h):
        if self.mat[j][i] != -1:
          row.append(self.mat[j][i])

      short = self.h - len(row)
      if short > 0:
        row.reverse()
        for k in range(short):
          row.append(-1)
        row.reverse()
      
      pivot_mat.append(row)

    mat = [ [-1]*5 for i in range(self.h) ]
    for i in range(self.h):
      for j in range(5):
        mat[i][j] = pivot_mat[j][i]

    self.mat = mat

while True:
  h = int(input())
  if h==0: exit()
  mat = []
  for _ in range(h):
    mat.append(list(map(int,input().split())))
  puzzle = Puzzle(mat, h)

  while True:
    if puzzle.calc():
      puzzle.flatten()
    else:
      break

  print(puzzle.score)


Measured memory_bytes: 5628
import java.util.Scanner;

class Main{
 
 public static void main(String args[]){

  Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();

    int sp = a*b;
    int pm = (a+b)*2;
      System.out.println(sp + " " + pm);
 }
}



Measured memory_bytes: 26136
#include <stdio.h>

int main(){
	int a,b,c;	
	scanf("%d", &a);
	scanf("%d %d", &b, &c);
	
	for(int i = b; i<=c; i++){
		
		if (i%a == 0){
			printf("OK\n");
			return 0;
		}	
	}
	
	printf("NG\n");
	
return 0;
}

Measured memory_bytes: 1632
#pragma region head
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rrepi(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
template <class T>
inline bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
    preprocess() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} ____;
#pragma endregion head

#pragma region library,
// Time Complexity: faster than O(logN)[O(ArkInv(N))]
// UnionFind.data: if minus -> size of subtree (node is root)
// if plus -> parent of the node
struct UnionFind {
    vector<int> data;
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
    int find(int x) {
        if (data[x] < 0) return x;
        return data[x] = find(data[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    int size(int x) {
        return (-data[find(x)]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
};
#pragma endregion library

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
    }
    set<int> root;
    rep(i, n) {
        root.emplace(uf.find(i));
    }
    cout << root.size() - 1 << '\n';
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int64_t> h(n + 2);
  for (int i = 1; i <= n; i++) cin >> h.at(i);
  vector<vector<vector<int64_t>>> dp(n + 2, vector<vector<int64_t>>(k + 1, vector<int64_t>(n + 2, 1LL << 60)));
  dp.at(0).at(0).at(0) = 0;
  for (int i = 1; i <= n + 1; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= i; l++) {
        dp.at(i).at(j).at(i) = min(dp.at(i).at(j).at(i), dp.at(i - 1).at(j).at(l) + abs(h.at(i) - h.at(l)));
        if (j > 0) {
          dp.at(i).at(j).at(l) = min(dp.at(i).at(j).at(l), dp.at(i - 1).at(j - 1).at(l));
        }
      }
    }
  }
  int64_t ans = 1ll << 60;
  ans = min(ans, dp.at(n + 1).at(k).at(n + 1) / 2);
  cout << ans << endl;
}


Measured memory_bytes: 219008
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main()
{
    char w[16], t[1024], *p;
    scanf(" %s", w);
    int ans=0;
    for(p=w; *p; p++) *p=toupper(*p);
    while(scanf(" %s", t)) {
        if(strcmp(t, "END_OF_TEXT")==0) break;
        for(p=t; *p; p++) *p=toupper(*p);
        if(strcmp(w, t)==0) ans++;
    }
    printf("%d\n", ans);
    return 0;
}

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

long double pi = 3.14159265358979;

int main() {
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  long double angle1 = 360 * (h * 60 + m) / 720 * pi / 180;
  long double angle2 = 360 * m / 60 * pi / 180;
  long double ans = sqrt(a * a + b * b - 2. * a * b * cos(abs(angle1 - angle2)));
  cout <<fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 4156
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        
        long ans = 0;
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                if(i*j>=n) break;
                ans++;
            }
        }
        
        System.out.println(ans);
    }
    
}

Measured memory_bytes: 35712
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define Ans(s) cout << s << endl

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

typedef long long ll;
typedef vector<int> inv;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main()
{
	int w, h, x, y;
	cin >> w >> h >> x >> y;

	cout << setprecision(9) << (double)w * (double)h / 2.0 << " ";

	if (w % 2 == 0 && h % 2 == 0)
	{
		if (w / 2 == x && h / 2 == y)
		{
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

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

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

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

void f(ll rest,string s){
    if(rest==0){
        cout<<s<<endl;
    }else{
        for(char c='a';c<='c';c++){
            f(rest -1,s+c);
        }
    }
}


int main(){
    ll n,q;
    string s;
    cin>>n>>q>>s;
    vector<ll> b(n);
    b[0]=0;
    
    rep(i,n-1) {
        if(s[i]=='A' && s[i+1]=='C') b[i+1]=b[i]+1;
        else b[i+1]=b[i];
    }
    
    vector<pair<ll,ll>> a(q);
    rep(i,q) cin>>a[i].first>>a[i].second;
    
    rep(i,q){
        cout<<b[a[i].second-1]-b[a[i].first-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a+b)%24;
}

Measured memory_bytes: 256
A, V = map(int, input().split(' '))
B, W = map(int, input().split(' '))
T = int(input())

distance = abs(A - B)
speed = V - W

if V - W <= 0:
    print('NO')
    exit(0)

t = distance // speed
if distance % speed == 0:
    if t <= T:
        print('YES')
    else:
        print('NO')
else:
    if t + 1 <= T:
        print('YES')
    else:
        print('NO')

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

int main() {
	const long long M=1000000007; 
	int n;
	long long n10=1, n9=1, n8=1, ans;
	cin>>n;
	while(n--){
		n10*=10; n10%=M;
		n9*=9; n9%=M;
		n8*=8; n8%=M;
	}
	ans=M+M+n10-n9-n9+n8;
	ans%=M;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    long Q;
    long K;
    cin >> N;
    cin >> K;
    cin >> Q;
    
    vector<int> A(Q);
    for(int i=0; i<Q; i++){
        cin >> A[i];
    }

    vector<long> point(N, K-Q);

    for(int i=0; i<Q; i++){
        point[A[i] - 1] += 1;
    }
    

    for(int i=0; i<N; i++){
        if(point[i] <= 0){
            printf("No\n");
        }else{
            printf("Yes\n");
        }
    }

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	string s; cin >> s;
	if (s.size() < 26) {
		vector<bool> appears(26, false);
		for (char c : s) {
			appears[c - 'a'] = true;
		}
		for (int i = 0; i < 26; ++i) {
			if (!appears[i]) {
				cout << s << (char)(i + 'a') << endl;
				break;
			}
		}
	} else {
		int firstDec = -1;
		for (int i = 24; i >= 0; --i) {
			if (s[i] < s[i+1]) {
				firstDec = i;
				break;
			}
		}
		if (firstDec == -1) {
			cout << -1 << endl;
		} else {
			char letterToTake = '{';
			for (int i = firstDec + 1; i < 26; ++i) {
				if (letterToTake > s[i] && s[i] > s[firstDec]) {
					letterToTake = s[i];
				}
			}
			for (int i = 0; i < firstDec; ++i) {
				cout << s[i];
			}
			cout << letterToTake << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 300000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, a[N], b[N], fen[N];
void add(int id, int x){
	if (id == 0) cout << "Fuck" << endl;
	for (; id < N; id += id & (-id)) fen[id] += x;
}

int get(int id){
	int res = 0;
	for (; id > 0; id -= id & (-id)) res += fen[id];
	return res;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++){
		if (i % 2 == 1) cin >> a[i / 2 + 1];
		else cin >> b[i / 2];
		if (i % 2 == 1) if (a[i / 2 + 1] % 2 == 0) return cout << "No", 0;
		if (i % 2 == 0) if (b[i / 2] % 2 == 1) return cout << "No", 0;
	}
	int ans = 0;
	for (int i = 1; i <= (n / 2) + (n % 2); i++){
		ans += i - 1 - get(a[i] - 1);
		add(a[i], 1);
	}
	memset(fen, 0, sizeof fen);
	for (int i = 1; i <= (n / 2); i++){
		ans += i - 1 - get(b[i] - 1);
		add(b[i], 1);
	}
//	cout << ans << '\n';
	memset(fen, 0, sizeof fen);
	int res = 0;
	for (int i = 1; i <= n; i++){
		if (i % 2 == 1) res += i - 1 - get(a[i / 2 + 1] - 1);
		else res += i - 1 - get(b[i / 2] - 1);
		if (i % 2 == 1) add(a[i / 2 + 1], 1);
		else add(b[i / 2], 1);
//		cout << res << '\n';
	}
//	cout << res << '\n';
	if (res % 3 != 0) return cout << "No", 0;
	cout << (res / 3 == ans?"Yes":"No");
//	cout << (ans % 3 == 0?"Yes":"No");










	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll LINF=0x1fffffffffffffff;
const vector<ll> dx={1,0,0,-1,1,1,-1,-1};
const vector<ll> dy={0,1,-1,0,1,-1,1,-1};
int main(){
	ll h,w;
	cin>>h>>w;
	vector<string> a(h);
	rep(i,0,h) cin>>a[i];
	vector<vector<ll>> m(h,vector<ll>(w,LINF));
	queue<pair<ll,ll>> q;
	rep(i,0,h) rep(j,0,w) if(a[i][j]=='#'){
			m[i][j]=0;
			q.push({i,j});
	}
	while(!q.empty()){
		ll x=q.front().first,y=q.front().second;
		q.pop();
		rep(i,0,4){
			ll x2=x+dx[i],y2=y+dy[i];
			if(x2<0||x2>=h||y2<0||y2>=w) continue;
			if(a[x2][y2]=='#') continue;
			if(m[x2][y2]<=m[x][y]+1) continue;
			m[x2][y2]=m[x][y]+1;
			q.push({x2,y2});
		}
	}
	ll ans=0;
	rep(i,0,h)rep(j,0,w){
		if(ans<m[i][j]) ans=m[i][j];
	}
	cout<<ans;
}
    

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

P dfs(const vvll& g, ll idx, ll par) {
  P ans = make_pair(-1ll, idx);
  for (auto it : g[idx]) {
    if (it == par)
      continue;
    chmax(ans, dfs(g, it, idx));
  }
  ans.first++;
  return ans;
}

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

  ll n;
  cin >> n;
  vvll g(n);
  rep(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  auto p = dfs(g, 0, -1);
  auto [diameter, idx] = dfs(g, p.second, -1);

  cout << ((diameter % 3 != 1) ? "First" : "Second") << endl;

  return 0;
}


Measured memory_bytes: 35784
"""
Writer: SPD_9X2
https://atcoder.jp/contests/agc007/tasks/agc007_d

まぁdpだよね
選択は
1.前の奴から引き継ぐ
2.新たに始める
の2択か？

ABCDの4つを同時に回収するとき
Aアメ→Dコインまでの時間は
max(3*(D-A),T+D-A)

待ち時間がちょうどないくらいが望ましいはず
すなわち、2*(D-A)と Tの差が小さくなるように選ぶべき？

左から歩いて行き、毎回止まって待つ場合
時間はE+NTである
ここからどれだけ減らせるかを基準に考えてみよう

T以内にx個追加で回ってこれた場合、減少するのはxT
x個回ってきたが、aだけ時間制限を超えた場合、減少はxT-a
少なくとも回れるならばすべて回ったほうが良い→右方向T/2以下にあるやつは確定で同時に取る
そうでない場合、新たに始める or x-増加分　のコストを払うを選択できる

これをうまくdpに落とし込めないか？？

dp[ai][連続/始点] = その頂点が始点 or 連続点の場合の減少量の最大値
始点は,T/2より1つだけ右にある要素にあげるdpをする(二分探索で位置を求める)
連続の場合、+1のところの連続or始点にあげるdpをする

あげるものは、E+NTからの減少量。よって最大値を求める

始点から上げる場合
iからT/2より+1右にある要素jの始点にあげる場合、(j-i-1)*T 可算
連続にあげる場合は、あまり分を考慮
(j-i)*T - 2*(A[j]-A[i])-T

連続から始点にあげる場合、+-0であげちゃう
連続から連続にあげる場合、T-(A[i+1]-A[i])*2 可算

大体おｋだと思うけど　始点と終点の処理は？
始点は考慮する必要無し
終点は…ちょっと面倒くさい　座標infをおいておけばいいかな
座標infの始点が答えになりそう
"""
import bisect
N,E,T = map(int,input().split())

A = list(map(int,input().split()))
A.append(float("inf"))

dp = [[float("-inf")] * 2 for i in range(N+1)]
dp[0][0] = 0

for i in range(N):

    j = bisect.bisect_right(A,A[i] + T//2)
    dp[j][0] = max(dp[j][0] , dp[i][0] + (j-i-1)*T )
    dp[j][1] = max(dp[j][1] , dp[i][0] + (j-i)*T - (2*(A[j]-A[i]) - T) )

    dp[i+1][0] = max(dp[i+1][0] , dp[i][1])
    dp[i+1][1] = max(dp[i+1][1] , dp[i][1] + T - (A[i+1]-A[i])*2 )

#print (dp)
print (E+N*T - dp[-1][0])


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

int main() { 
  int a,b,c;
  cin >> a >> b >> c;
  if ((a * 100 + b * 10 + c) % 4 == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost::multiprecision;  
//using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
//inline int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
//inline int lcm(int a,int b){ return a / gcd(a,b) * b;}
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    int q;
    string s;
    cin >> s >> q;
    deque<char> dq;

    rep(i,s.size()){
        dq.emplace_back(s[i]);
    }

    bool rev = false;
    rep(i,q){
        int t;
        cin >> t;
        if(t == 1){
            rev ^= true;
        }else{
            int f;
            char c;
            cin >> f >> c;
            if(rev){
                f = 3 - f;
            }
            if(f == 1){
                dq.emplace_front(c);
            }else{
                dq.emplace_back(c);
            }
        }
    }

    if(rev) reverse(all(dq));

    for(auto e : dq){
        cout << e;
    }
    cout << '\n';

    return 0;
}



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

namespace AtCoder.Contests.ABC160
{
    /// <summary>
    /// 
    /// </summary>
    static class E
    {
        static void Main(string[] args)
        {
            var x = NextInt();
            var y = NextInt();
            var a = NextInt();
            var b = NextInt();
            var c = NextInt();
            var ps = ReadLongArray().OrderByDescending(_ => _).ToArray();
            var qs = ReadLongArray().OrderByDescending(_ => _).ToArray();
            var rs = ReadLongArray().OrderByDescending(_ => _).ToArray();


            var taberu = ps.Take(x).Concat(qs.Take(y)).Concat(rs).OrderByDescending(_ => _).ToArray();
            Console.WriteLine(taberu.Take(x + y).Sum());
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 47368
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

#define int long long

const int N = 3003;
const int MOD = 1e9 + 7;
const int INV2 = 500000004;

int mul(int a, int b) {
   return (a * b) % MOD; 
}

int add(int a, int b) {
   return (a + b) % MOD;
}

int n;
int dp[N][N];

void rec_dp(int x, int y) {
   vector<pair<int, int>> torel;
   for (int i = 0; i < n; i++) {
      if (i == x || i == y) {
         for (int j = 0; j < n; j++) {
            torel.push_back({i, j});
         }
      } else {
         torel.push_back({i, x});
         torel.push_back({i, y});  
      }
   }
   vector<tuple<int, int, int>> rval;
   for (auto t : torel) {
      int i, j;
      tie(i, j) = t;
      if (i == j) {
         rval.push_back(make_tuple(i, j, dp[i][j]));
         continue;
      }
      if (i != x && i != y && j != x && j != y) {
         rval.push_back(make_tuple(i, j, dp[i][j]));
         continue;  
      }
      if (i == x && j == y) {
         rval.push_back(make_tuple(i, j, mul(add(dp[i][j], dp[j][i]), INV2)));
         continue;
      }
      if (i == y && j == x) {
         rval.push_back(make_tuple(i, j, mul(add(dp[i][j], dp[j][i]), INV2)));
         continue;
      }
      if (i == x) {
         rval.push_back(make_tuple(i, j, mul(add(dp[i][j], dp[y][j]), INV2)));
         continue;
      }
      if (i == y) {
         rval.push_back(make_tuple(i, j, mul(add(dp[i][j], dp[x][j]), INV2)));
         continue;
      }
      if (j == x) {
         rval.push_back(make_tuple(i, j, mul(add(dp[i][j], dp[i][y]), INV2)));
         continue;
      }
      if (j == y) {
         rval.push_back(make_tuple(i, j, mul(add(dp[i][j], dp[i][x]), INV2)));
         continue;
      }
      assert(false);
   }
   for (auto t : rval) {
      int i, j, c;
      tie(i, j, c) = t;
      dp[i][j] = c;
   }
}

signed main() {
   ios_base::sync_with_stdio(false);
   cin.tie(0);

   int q;
   cin >> n >> q;
   vector<int> a(n);
   for (auto &t : a) {
      cin >> t;
   }
   for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
         dp[i][j] = (a[i] > a[j]); 
      }
   }
   for (int i = 0; i < q; i++) {
      int x, y;
      cin >> x >> y;
      x--;
      y--;
      rec_dp(x, y);
   }
   int ans = 0;
   for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
         ans = add(ans, dp[i][j]);
      }
   }
   // for (int i = 0; i < n; i++) {
   //    for (int j = 0; j < n; j++) {
   //       cerr << mul(2, dp[pnt][i][j]) << ' ';
   //    }
   //    cerr << endl;
   // }
   for (int i = 0; i < q; i++) {
      ans = mul(ans, 2);
   }
   cout << ans << endl;
}


Measured memory_bytes: 71656
// https://atcoder.jp/contests/abc144/tasks/abc144_f

#include "algorithm"
#include "iomanip"
#include "iostream"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

void solve() {
  ll N, M;
  cin >> N >> M;

  VVL edges(N);
  rep(i, M) {
    ll s, t;
    cin >> s >> t;
    s--, t--;
    edges[s].push_back(t);
  }

  // その頂点から点 N までの辺の数の期待値
  auto calc_dp = [&](ll rm_from, ll rm_to) {
    V<double> dp(N);
    for (ll u = N - 2; u >= 0; u--) {
      double e = 0;

      for (auto v : edges[u]) {
        if (u == rm_from && v == rm_to) continue;
        e += dp[v];
      }

      ll deg = edges[u].size();
      if (u == rm_from) deg--;

      e /= deg;
      e++;
      dp[u] = e;
    }

    return dp;
  };

  V<double> dp = calc_dp(-1, -1);
  double res = dp[0];

  // 各頂点について、期待値の大きい点への辺を消す
  rep(rm_from, N - 1) {
    if (edges[rm_from].size() == 1) continue;

    ll rm_to;
    {
      double max_e = -1;
      for (auto rv : edges[rm_from]) {
        if (chmax(max_e, dp[rv])) rm_to = rv;
      }
    }

    auto rdp = calc_dp(rm_from, rm_to);
    chmin(res, rdp[0]);
  }

  cout << fixed << setprecision(10) << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int main()
{
long long n,p,j,wm;
long long w[100000];
long long t[100000];
long i;
cin>>n>>p;
for(i=0;i<n;i++)
{
cin>>w[i]>>t[i];
}
sort(w,w+n,greater<int>());
wm=w[0];
sort(t,t+n,greater<int>());
j=0;
for(i=0;i<n;i++)
{
if(t[i]>=wm&&p>0)
{p-=t[i];j++;}
}
if(p>0){j+=((p+wm-1)/wm);}
cout<<j;
return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
typedef long long ll;
#define MN 200005
//#define getchar() (S==TT&&(TT=(S=BB)+fread(BB,1,1<<15,stdin),TT==S)?EOF:*S++)
//char BB[1<<15],*S=BB,*TT=BB;
inline int read()
{
	int x=0,f=0;char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) f=c=='-';
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<3)+(x<<1)+(c^48);
	return f?-x:x;
}
struct edge{
	int to,nxt;
}e[MN<<1];
int n,h[MN],cnt,mx[MN],siz[MN],son1[MN],ans[MN],son2[MN];
void ins(int x,int y){e[++cnt].nxt=h[x];h[x]=cnt;e[cnt].to=y;}
void dfs1(int x,int f,int v,int *son)
{
	son[x]=1;
	for(int i=h[x];i;i=e[i].nxt)
	{
		if(e[i].to<v&&e[i].to!=f)
		{
			dfs1(e[i].to,x,v,son);
			son[x]+=son[e[i].to];
		}
	}
}
void dfs2(int x,int f)
{
	mx[x]=std::max(x,mx[f]);
	for(int i=h[x];i;i=e[i].nxt) if(e[i].to!=f) dfs2(e[i].to,x);
	if(x==mx[x]){dfs1(x,f,mx[f],son1);dfs1(x,f,x,son2);}
}
void dfs3(int x,int f)
{
	if(x!=1)
	{
		if(mx[x]==x) ans[x]=son1[x];
		else if(mx[f]==f) ans[x]=son2[x]-son1[x];
		ans[x]+=ans[f];
	}
	for(int i=h[x];i;i=e[i].nxt) if(e[i].to!=f) dfs3(e[i].to,x);
}
int main()
{
//	freopen("tree.in","r",stdin);
//	freopen("tree.out","w",stdout);
	n=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		ins(x,y);
		ins(y,x);
	}
	dfs2(1,0);
	dfs3(1,0);
	for(int i=2;i<=n;i++){printf("%d",ans[i]);putchar(i==n?'\n':' ');}
	return 0;
}


Measured memory_bytes: 21376
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

    vector<long long> s(a);
    for (int i = 0; i < a; i++) {
        cin >> s[i];
    }

    vector<long long> t(b);
    for (int i = 0; i < b; i++) {
        cin >> t[i];
    }

    for (int i = 0; i < q; i++) {
        long long x;
        cin >> x;

        long long d_min = 20000000000LL;
        vector<long long>::iterator sp, tp;

        sp = lower_bound(s.begin(), s.end(), x);
        if (sp != s.begin()) {
            tp = lower_bound(t.begin(), t.end(), *(sp - 1));
            long long d = min(tp == t.begin() ? 20000000000LL : (x - *(tp - 1)),
                tp == t.end() ? 20000000000LL : (x - *(sp - 1)) + (*tp - *(sp - 1)));
            if (d_min > d) {
                d_min = d;
            }
        }
        if (sp != s.end()) {
            tp = lower_bound(t.begin(), t.end(), *sp);
            long long d = min(tp == t.begin() ? 20000000000LL : (*sp - x) + (*sp - *(tp - 1)),
                tp == t.end() ? 20000000000LL : (*tp - x));
            if (d_min > d) {
                d_min = d;
            }
        }

        tp = lower_bound(t.begin(), t.end(), x);
        if (tp != t.begin()) {
            sp = lower_bound(s.begin(), s.end(), *(tp - 1));
            long long d = min(sp == s.begin() ? 20000000000LL : (x - *(sp - 1)),
                sp == s.end() ? 20000000000LL : (x - *(tp - 1)) + (*sp - *(tp - 1)));
            if (d_min > d) {
                d_min = d;
            }
        }
        if (tp != t.end()) {
            sp = lower_bound(s.begin(), s.end(), *tp);
            long long d = min(sp == s.begin() ? 20000000000LL : (*tp - x) + (*tp - *(sp - 1)),
                sp == s.end() ? 20000000000 : (*sp - x));
            if (d_min > d) {
                d_min = d;
            }
        }

        cout << d_min << endl;
    }
}


Measured memory_bytes: 2944
N, K, C = map(int, input().split())
S = input()
p = -C-1
L = []
R = []
for i in range(N):
  if i>p+C and S[i]=='o':
    L.append(i)
    p = i
p = N+C
for i in range(N-1,-1,-1):
  if p>C+i and S[i]=='o':
    R.append(i)
    p = i
R = R[::-1]
if len(L)>K or len(R)>K:
  exit()
ans = []
for a,b in zip(L,R):
  if a==b:
    ans.append(str(a+1))
print('\n'.join(ans))

Measured memory_bytes: 35592
#include <stdio.h>

int parking(int n,int a,int b){
  int pay = n*a;
  if(b < pay) pay = b;
  return pay;
}

int main(){
  int n,a,b;
  scanf("%d %d %d",&n,&a,&b);
  printf("%d\n",parking(n,a,b));
  return 0;
}


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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    string ss = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int len = s.size();
    int in;
    for(int i=0;i<len;i++)
    {
                //cout<<"i : "<<i<<endl;

        in = s[i]-ss[0];
        in+=n;
       // cout<<"in : "<<in<<endl;
        in%=26;
        //cout<<"in : "<<in<<endl;
        //cout<<s[i]<< " "<<ss[in]<<endl;
        s[i]=ss[in];
        //cout<<s[i]<<endl;
    }
    //cout<<"result " <<endl;
    cout<<s<<endl;

    return 0;

//    2
//ABCXYZ
//CDEZAB

}


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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main(){
    /* code */ 
    string S; cin >> S;
    if(S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    
    size_t w, h, n;

    std::cin >> w >> h >> n;

    size_t lx = 0, rx = w, dy = 0, uy = h;

    for(size_t i = 0; i < n; i++){
        size_t x, y, a;
        std::cin >> x >> y >> a;

        if(a == 1){
            lx = std::max(lx, x);
        }else if(a == 2){
            rx = std::min(rx, x);
        }else if(a == 3){
            dy = std::max(dy, y);
        }else{
            uy = std::min(uy, y);
        }
    }

    if(rx < lx || uy < dy){
        std::cout << 0 << std::endl;
    }else{
        std::cout << (rx - lx) * (uy - dy) << std::endl;
    }

    
    return 0;
}


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

int N;

struct V {
  ll x, y;

  V(ll x = 0, ll y = 0): x(x), y(y) {};

  ll r2() const {
    return dot(*this);
  }

  V& operator += (const V &v) {
    x += v.x;
    y += v.y;
    return *this;
  }

  ll cross(const V& that) const {
    return x * that.y - that.x * y;
  }

  ll dot(const V& that) const {
    return x * that.x + y * that.y;
  }

  bool operator < (const V &that) const {
    // TLE?
    return atan2(y, x) < atan2(that.y, that.x);
    // if(x == 0 && y == 0) return true;

    // ll c = cross(that);
    // if(c != 0) return c > 0;
    // if(dot(that) > 0) return r2() < that.r2();
    // if(y == 0) return x > 0;
    // return y > 0;
  }
};

vector<V> x;

int main () {
  cin >> N;

  rep(i,N) {
    ll a, b;
    cin >> a >> b;
    x.emplace_back(a, b);
  }

  sort(all(x));

  ll ans = 0;
  rep(i,N) {
    V c(0, 0);
    rep(j,N) {
      c += x[(i+j)%N];
      ans = max(ans, c.r2());
    }
  }

  cout << fixed << setprecision(12) << sqrt(ans) << endl;

  return 0;
}


Measured memory_bytes: 256
def keta(n):
  sum = 0
  while n>0:
    sum += n%10 
    n = n//10 
  return(sum)
def mium():
  N, A, B = map(int, input().split())
  ans = 0
  for i in range (N):
    a = keta(i+1)
    if A <= a and a <= B:
      ans += i+1
  print(ans)
if __name__ == "__main__":
  mium()

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

using namespace std;

int main() {
  int Tc; cin >> Tc;
  bool a = 0;
  while(Tc--) {
    int N; cin >> N;
    if(a) cout << endl;
    a = 1;
    
    char grid[N+2][N+2];
    for(int i=0; i<N; i++) {
      fill(grid[i], grid[i]+N, ' ');
      grid[i][N] = '\0';
    }

    const int dx[] = {0,1,0,-1};
    const int dy[] = {-1,0,1,0};
    
    int x = 0, y = N;
    int n = N;
    for(int i=0; i<N; i++) {
      for(int l=0; l<n; l++) {
	y += dy[i%4], x += dx[i%4];
	grid[y][x] = '#';
      }
      if(i%2 == 0 && i>=2) n -= 2;
      if(i%4 == 0) x --;
      if(i%4 == 1) y --;
      if(i%4 == 2) x ++;
      if(i%4 == 3) y ++;
    }
    
    for(int i=0; i<N; i++) {
      cout << grid[i] << endl;
    }
  }
  
  return 0;
}

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

using namespace std;
typedef long long LL;

LL INF = (1LL<<31) - 1;
int N;
unsigned int A[1<<18];

void update(int i, int x){
  i += N;
  A[i] = x;

  i /= 2;
  int li = i*2, ri = i*2+1;
  while(i > 0){
	A[i] = min(A[li], A[ri]);
	i /= 2;
	li = i*2, ri = i*2+1;
  }
}

int find(int s, int t, int v = 1, int l = 0, int r = N){
  if(t <= l || r <= s || r <= l) return INF;
  if(s <= l && r <= t) return A[v];
  return min(find(s, t, v*2, l, (l+r)/2),
			 find(s, t, v*2+1, (l+r)/2, r));
}

int main(){
  int Q; scanf("%d %d", &N, &Q);
  int N_ = 2;
  while(N_ < N) N_ <<= 1;
  N = N_;

  for(int i=0;i<N*2;++i)
	A[i] = INF;
  
  while(Q--){
	int c, x, y;
	scanf("%d %d %d", &c, &x, &y);
	if(c) printf("%d\n", find(x, y+1));
	else update(x, y);
  }
}

Measured memory_bytes: 2036
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to,cap,rev; 
	edge (int from, int to, int cap, int rev){
		this->from=from; this->to=to; this->cap=cap; this->rev=rev;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;


#define M 1000000007
int main(){
	int n;
	cin >> n;
	ll ans = 1;
	for (int i = 1; i <= n; i++) {
		ans = ans*i%M;
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);
const int INF=100000000;

int N; vi h;
void input()
{
    cin>>N;
    h.emplace_back(0);
    for(int i=0;i<N;++i){
        int a; cin>>a; h.emplace_back(a);
    }
}

void solve()
{
    int ans=0;
    int plus=0; int minus=0;
    for(int i=0;i<N;++i){
        if(h[i]<=h[i+1]) plus=h[i+1];
        else{
            ans+=plus-minus;
            plus=h[i+1]; minus=h[i+1];
        }
    }
    ans+=plus-minus;
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main()
{
	int n, m;
	int ans = 1;
	scanf("%d %d", &n, &m);
	
	for(int i = 0; i < n; i++){
		if(ans <= m){
			ans*= 2;
		}else{
			ans+=m;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1696
#ダイクストラ法
import heapq
def dijkstra(s):
    p=[x for x in range(n)]#親の記憶
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * n # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for d, u in e[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                p[u]=v
                heapq.heappush(hq, (tmp, u))
    return p

n,m = map(int,input().split())
#重み付き有向グラフの隣接リストe(重み=1)
e = [[] for _ in range(n)]
t=1
for _ in range(m):
    a,b= map(int,input().split())
    a,b = a-1, b-1
    e[a].append((t, b))
    e[b].append((t, a))

ans = dijkstra(0)
print('Yes')
for i in range(1,n):
  print(ans[i]+1)


Measured memory_bytes: 67012