akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL);
    ll n;
    cin>>n;
    ll dp[n][3];
    memset(dp,0,sizeof(dp));
    for(ll i=0;i<n;i++){
        ll a[3];
        cin>>a[0]>>a[1]>>a[2];
        if(i==0){
            dp[0][0]=a[0];
            dp[0][1]=a[1];
            dp[0][2]=a[2];
        }
        else{
            for(ll x=0;x<3;x++){
                for(ll y=0;y<3;y++){
                    if(x!=y){
                        dp[i][x]=max(dp[i][x],dp[i-1][y]+a[x]);
                    }
                }
            }
        }
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  COMinit();
  ll n,a,b,c;
  cin >> n >> a >> b >> c;
  ll ans=0;
  exrep(m,n,2*n-1){
    ll bunsi=(modpow(a,n)*modpow(b,m-n)%MOD+modpow(b,n)*modpow(a,m-n)%MOD)*m*100%MOD;
    ll bunbo=modpow(a+b,m)*(100-c)%MOD;
    ans+=COM(m-1,n-1)*bunsi%MOD*modinv(bunbo)%MOD;
    ans%=MOD;
  }
  cout << ans << endl;
    
}


Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
string s;
int judge=0;
int main()
{
    cin>>s;
    if(s.size()%2==1)
        judge++;
    if(s[0]==s[s.size()-1])
        judge++;
    if(judge==1)
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
    return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


S = input()
T = input()


def n_rewrite(S, T):
    assert len(S) == len(T), (S, T)
    ret = 0
    for s, t in zip(S, T):
        if s != t:
            ret += 1
    return ret


ans = 10**9
for i in range(len(S) - len(T) + 1):
    ans = min(ans, n_rewrite(T, S[i:i + len(T)]))

print(ans)


Measured memory_bytes: 68600
// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }

using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 205
#define MAX_M 100005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
int dist[MAX_N][MAX_N];
/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
//  WF("output.txt");
	DF("err.txt");

	int N, M, R;
	scanf("%d %d %d", &N, &M, &R);
	vector <int> rs;
	for (int i = 0; i < R; i++) {
		int r;
		scanf("%d", &r);
		rs.emplace_back(r);
	}
	sort(ALL(rs));
	for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++) if (i != j)
		dist[i][j] = INF;
	while (M--) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		dist[a][b] = dist[b][a] = c;
	}
	for (int k = 1; k <= N; k++) for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++)
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	int res = INF;
	do{
		int now = 0;
		for (int k = 1; k < R; k++)
			now += dist[rs[k - 1]][rs[k]];
		res = min(res, now);
	} while (next_permutation(ALL(rs)));
	printf("%d\n", res);
}

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

int main() {
  int N;
  cin >> N;
  string S ;
  for(int i = 0; i < N ; i++ ){
    cin >> S ;
    if ( S == "Y" ){
      cout << "Four" << endl;
      break;
    }else if( i == N-1){
      cout << "Three" << endl;
    }

  }
  
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	LL N, M;
	cin >> N >> M;
	vector<LL> A(N), sum(N+1);
	rep(i,N) cin >> A[i];
	rep(i,N) sum[i+1]=sum[i]+A[i];
	rep(i,N) sum[i+1]%=M;
	map<LL,LL> m;
	rep(i,N+1) m[sum[i]]++;
	LL ans=0;
	for(auto itr:m) ans+=itr.second*(itr.second-1)/2;
	cout << ans << endl;

	return 0;
}

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

const int MAX=1e6;

int main(){
  int n;
  std::cin >> n;
  std::vector<int> a(n);

  rep(i,n)std::cin >> a[i];
  sort(a.begin(),a.end());


  std::vector<int> p;
  int ans=0;

  int prime[MAX+1]={};

  for (int i = 0; i < n; i++) {
    bool ok=true;
    if(i+1<n && a[i]==a[i+1])ok=false;
    if(prime[a[i]]!=0)continue;
    for (int j = a[i]; j <= MAX; j+=a[i]) {
      prime[j]=1;
    }

    if(ok){
      ans++;
    }

  }

  std::cout << ans << '\n';


  return 0;
}


Measured memory_bytes: 7984
n,m = map(int,input().split())

from collections import defaultdict
G = defaultdict(list)

for _ in range(m):
    l,r,d = map(int,input().split())
    G[l-1].append((r-1, d))
    G[r-1].append((l-1, -d))


pos = [float("inf") for _ in range(n)]
for i in range(n):
    if pos[i] == float("inf"):
        stack = [i]
        pos[i] = 0
    while stack:
        p = stack.pop()
        for a, d in G[p]:
            if pos[a] == float("inf"):
                pos[a] = pos[p] + d
                stack.append(a)

for i in range(n):
    for to, d in G[i]:
        if pos[to] - pos[i] != d:
            print("No")
            exit()

print("Yes")



Measured memory_bytes: 95704
import sys
input = sys.stdin.readline
N,Q = map(int,input().split())
A = list(map(int,input().split()))
qs = [tuple(map(int,input().split())) for i in range(Q)]

class BinaryIndexedTree:
    def __init__(self,size):
        self.N = size
        self.bit = [0]*(size+1)
    def add(self,x,w): # 0-indexed
        x += 1
        while x <= self.N:
            self.bit[x] += w
            x += (x & -x)
    def _sum(self,x): # 1-indexed
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= (x & -x)
        return ret
    def sum(self,l,r): # [l,r)
        return self._sum(r) - self._sum(l)
    def __str__(self): # for debug
        arr = [self.sum(i,i+1) for i in range(self.N)]
        return str(arr)
bit = BinaryIndexedTree(N)

for i,a in enumerate(A):
    bit.add(i,a)
for q in qs:
    if q[0]:
        l,r = q[1:]
        print(bit.sum(l,r))
    else:
        p,x = q[1:]
        bit.add(p,x)

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


def main():
    N = int(input())
    A = list(map(int, input().split()))
    if N == 0 and A[0] == 1:
        print(1)
        return
    if N == 0:
        print(-1)
        return
    if A[0] != 0:
        print(-1)
        return
    
    # 下から全く連結なしに子から枝を伸ばしたとして、部分木の個数を確認
    B = [0] * (N + 1)
    B[-1] = A[-1]
    for i in range(N - 1, -1, -1):
        B[i] = B[i + 1] + A[i]
    
    # 次に根から順にみてうまくつなぎ合わせ
    vertex = 1
    root = 1
    for i in range(1, N):
        if root * 2 - 1 < A[i]:
            print(-1)
            return
        if root < A[i]:
            root = min(B[i + 1], root * 2 - A[i])
            vertex += A[i] + root
        else:
            root = min(B[i + 1], root * 2 - A[i])
            vertex += A[i] + root
    
    # 最後N段目でつじつま合うか確認
    if root * 2 < A[-1]:
        print(-1)
        return
    vertex += A[-1]
    print(vertex)
    





if __name__ == "__main__":
    main()


Measured memory_bytes: 83268
#include<bits/stdc++.h>
using namespace std;
int n,m;
priority_queue<int,vector<int>,greater<int> >q;

int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        if(b<=m)q.push(a);
    }
    if(q.empty())printf("TLE\n");
    else{
        printf("%d\n",q.top());
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

int main(){
	static int n,t,s;
	static int a[3002],b[3002];
	
	scanf("%d%d%d",&n,&t,&s);
	rep1(i,n){
		scanf("%d%d",&a[i],&b[i]);
	}
	
	static int dp[3002][3002] = {};
	rep1(i,n){
		rep1(j,t){
			dp[i][j] = max ( dp[i-1][j] , dp[i][j-1] );
			if(j >= b[i] && (s-j)*(s-(j-b[i])) >= 0){
				dp[i][j] = max ( dp[i][j] , dp[i-1][j-b[i]] + a[i] );
			}
		}
	}
	
	printf("%d\n",dp[n][t]);
}

Measured memory_bytes: 36380
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int N,M,count=0;
  scanf("%d %d",&N,&M);
  int c[M+1];
  for(int i=0;i<M+1;i++)c[i]=0;
  for(int i=0;i<N;i++){
    int n;
    scanf("%d ",&n);
    int t[n];
    for(int j=0;j<n;j++) scanf("%d ",&t[j]);
    for(int j=0;j<n;j++)c[t[j]]++;
  }
  //for(int i=0;i<M+1;i++)printf("%d\n",c[i]);
  for(int i=0;i<M+1;i++){
    if(c[i]==N) count++;
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
int main() {
    string s;
    cin>>s;
    if (s=="ARC")
    {
        /* code */
        cout<<"ABC"<<endl;
    }
    else
    {
        cout<<"ARC"<<endl;
    }
    
    
}

Measured memory_bytes: 3624
import math

def modpow(a, n , mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a*a % mod
        n >>= 1
    return res

def calcp(n,j,mod):
    res = 1
    for i in range(n,n-j,-1):
        res = res * i %mod
    return res

def main():
    n,a,b = list(map(int, input().split()))
    MOD = 10**9+7
    NMAX = 2*10**5

    fact = [0 for i in range(NMAX+5)]
    fact[0] = 1
    invfact = [0 for i in range(NMAX+5)]
    invfact[0] = 1

    for i in range(NMAX):
        fact[i+1] = (fact[i]*(i+1))%(MOD)

    invfact[NMAX] = pow(fact[NMAX], MOD-2, MOD)
    for i in range(NMAX-1,0,-1):
        invfact[i] = (invfact[i+1] * (i+1)) % MOD

    ans = modpow(2,n,MOD)-1

    pa = calcp(n,a,MOD)*invfact[a]%MOD
    pb = calcp(n,b,MOD)*invfact[b]%MOD
    ans = ans - pa - pb;
    while ans < 0:
        ans += MOD
    print(ans)

        

main()

Measured memory_bytes: 54136
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define inf 1000000000
#define mod 1000000007
#define li 100005
#define FOR for(int i=1;i<=n;i++)
typedef pair< int,int > PII;
typedef long long int lo;
lo n,m,cev,b,a[51],dp[51][2501][51];
string s;
vector<int> v;
lo f(lo sira,lo topl,lo kac){
	lo cevap=0;
	//~ printf("%d %d %d\n",sira,topl,kac);
	if(sira>n && kac*m==topl) return 1;
	if(sira>n && kac*m!=topl) return 0;
	if(~dp[sira][topl][kac]) return dp[sira][topl][kac];
	cevap+=f(sira+1,topl+a[sira],kac+1);
	cevap+=f(sira+1,topl,kac);
	return dp[sira][topl][kac]=cevap;
}
int main(){
	memset(dp,-1,sizeof(dp));
	scanf("%lld %lld",&n,&m);
	FOR{
		scanf("%lld",&a[i]);
	}
	printf("%lld",f(1,0,0)-1);
	//~ printf("%d",cev);
	return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

#ifdef LOCAL
	#define debug(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define debug(...) 42
#endif

#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

inline string getString(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string getLine(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
typedef long long ll;

const int S=3000;
int r,c,k;
int grid[S+5][S+5];
ll dp[S+5][S+5][5];

ll Solve(int x,int y,int cnt)
{
	if(x==r-1 && y==c-1)return 0;
	if(dp[x][y][cnt]!=-1)return dp[x][y][cnt];

	ll mx=0;
	if(x+1<r)
	{
		mx=max(mx,grid[x+1][y]+Solve(x+1,y,1));
		mx=max(mx,Solve(x+1,y,0)); 
	}
	if(y+1<c)
	{
		if(cnt<3)
		{
			mx=max(mx,grid[x][y+1]+Solve(x,y+1,cnt+1));
		}
		mx=max(mx,Solve(x,y+1,cnt));
	}
	return dp[x][y][cnt]=mx;
}

int main()
{
	while(~sf("%d %d %d",&r,&c,&k))
	{
		mem(grid,0);
		for(int i=1;i<=k;i++)
		{
			int x,y,val;
			sf("%d %d %d",&x,&y,&val);
			x--,y--;
			grid[x][y]=val;
		}

		mem(dp,-1);
		ll ans=max(Solve(0,0,0),grid[0][0]+Solve(0,0,1));
		pf("%lld\n",ans);
	}
    return 0;
}



































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

using ll = long long;
ll modinv(ll a, ll m) {
	assert(m > 0);
	if (m == 1) return 0;
	a %= m;
	if (a < 0) a += m;
	assert(a != 0);
	if (a == 1) return 1;
	return m - modinv(m, a) * m / a;
}

template <int MOD_> struct modnum {
private:
	int v;
public:
	static const int MOD = MOD_;

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int () const { return v; }
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum operator ~ () const {
		modnum res;
		res.v = modinv(v, MOD);
		return res;
	}

	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= (~o);
	}

	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }

	friend modnum pow() {}
};

using num = modnum<998244353>;

num pow(num a, ll b){
	assert(b >= 0);
	if(b & 1) return a * pow(a, b-1);
	if(!b) return 1;
	return pow(a * a, b / 2);
}

vector<num> fact;
vector<num> ifact;

void init(){
	fact = {1};
	for(int i = 1; i < 11000000; i++) fact.push_back(i * fact[i-1]);
	ifact.resize(fact.size());
	ifact.back() = 1 / fact.back();
	for(int i = (int)ifact.size() - 1; i > 0; i--) ifact[i-1] = i * ifact[i];
}

num ncr(int n, int k){
	if(k < 0 || k > n) return 0;
	return fact[n] * ifact[k] * ifact[n-k];
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	init();
	num ans = 1;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) ans *= 3;
	vector<num> p2(n+1, 0);
	p2[0] = 1;
	for(int i = 1; i <= n; i++){
		p2[i] = 2 * p2[i-1];
	}
	for(int i = 0; i < n/2; i++){
		ans -= 2 * p2[i] * ncr(n, i);
	}
	cout << (int)ans << '\n';
}

Measured memory_bytes: 127068
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

vector <pii> ans;
int cnt[100010], N;
void add_ans(int x, int y) {
	ans.pb(pii(x, y));
}

int main() {
	scanf("%d", &N);
	if(N == (N&-N)) {
		puts("No");
		return 0;
	}
	puts("Yes");
	add_ans(1, 2); add_ans(2, 3);
	add_ans(1, N+3); add_ans(N+3, N+2); add_ans(N+2, N+1);
	for(int i=4;i+1<=N;i+=2) {
		add_ans(1, i); add_ans(i, i+1);
		add_ans(1, N+i+1); add_ans(N+i+1, N+i);
	}
	if(N % 2 == 0) {
		int x = (N+1);
		int a = 1<<(31-__builtin_clz(x));
		int b = x^a;
		if(a % 2 == 1) a += N;
		add_ans(a, N);
		if(b % 2 == 1) b += N;
		add_ans(b, N*2);
	}
	for(pii e : ans) printf("%d %d\n", e.Fi, e.Se);
	return 0;
}

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

int main()
{
  string S;
  cin >> S;
  string ans;
  if (S.size() < 26)
  {
    set<char> st;
    for (int i = 0; i < S.size(); i++)
    {
      st.insert(S[i]);
    }
    for (int i = 0; i < 26; i++)
    {
      char c = 'a' + i;
      if (st.find(c) == st.end())
      {
        ans = S + c;
        break;
      }
    }
    cout << ans << endl;
  }
  else
  {
    vector<char> p;
    bool max = true;
    string tmp = S;
    for (int i = S.size() - 1; i >= 1; i--)
    {
      p.push_back(S[i]);
      if (S[i - 1] - S[i] < 0)
      {
        decltype(S)::iterator it = S.begin() + i - 1;
        S.erase(it, S.end());
        sort(p.begin(), p.end());
        char supple;
        for (int j = 0; j < p.size(); j++)
        {
          if (p[j] > tmp[i - 1])
          {
            supple = p[j];
            break;
          }
        }
        ans = S + supple;
        max = false;
        break;
      }
    }
    if (max)
      cout << -1 << endl;
    else
    {
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 256
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <climits>
#include <set>

//#define int long long
typedef long long ll;
//#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define MOD 1000000007

using namespace std;

typedef vector<int> V;
typedef vector<V> VV;

ll N, T;
ll t[200010];

signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    cin >> N >> T;
    ll last = T;
    ll rest = 0;
    REP(i,N){
        cin >> t[i];
        if (i == 0) continue;
        if (t[i] < last) {
            rest += last - t[i];
        }
        last = t[i] + T;
    }

    cout << T * N - rest << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int n = 0;
        String s = sc.next();
        for(int i = 0; i < 4 ; i++){
            if(s.charAt(i) == '+' ){
                n++;
            }else{
                n--;
            }
        }

        System.out.println(n);
    }
}

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

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n - 1; ++i) {
        int a;
        cin >> a;
        mp[a]++;
    }
    for (int j = 1; j <= n; ++j) {
        cout << mp[j] << endl;
    }
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N, W; cin >> N >> W;
    ll dp[N+1][W+1];
    ll worth[N+1] = {}, value[N+1] = {};
    rep(i, N) cin >> worth[i+1] >> value[i+1];
    rep(i, N+1) rep(j, W+1) dp[i][j] = 0;
    //i番目の品物が重さw, 価値v
    //dp[i][j] = max(dp[i-1][j], dp[i-1][j-w] + v) when j-w >= 0
    for(int i = 1; i <= N; i++){
        int w = worth[i], v = value[i];
        for(int j = 0; j <= W; j++){
            if(j-w >= 0) dp[i][j] = max(dp[i-1][j], dp[i-1][j-w] + v);
            else dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
int INF =  1000000000;
using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i,0,n) cin >> h[i];
	sort(all(h));
	int mini = INF;
	rep(i,0,n-k+1){
		mini = min(mini,h[k+i-1]-h[i]);
	}
	cout <<mini << endl;
}


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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N;

  void init() {
    scanf("%lld", &N);
  }

  void solve() {
    ll ans = 0;
    while(N>=500) {
      N -= 500;
      ans += 1000;
    }
    while(N>=5) {
      N -= 5;
      ans += 5;
    }
    printf("%lld\n", ans);
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 256
from collections import deque

k = int(input())

lunlun = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

for i in range(k):
    s = lunlun.popleft()
    
    if s % 10 != 0:
        lunlun.append(10 * s + s % 10 - 1)
    lunlun.append(10 * s + s % 10)
    if s % 10 != 9:
        lunlun.append(10 * s + s % 10 + 1)

print(s)


Measured memory_bytes: 18816
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// use std::io::{stdout, Write, BufWriter};
// use std::cmp::min;

fn main() {
    input!{
        n: usize,
        v: [f64; n],
    }

    let mut v: Vec<i32> = v.into_iter().map(|v| v as i32).collect();
    {v.sort()}
    {v.reverse()}
    let v: Vec<f64> = v.into_iter().map(|v| v as f64).collect();

    let mut ans = (v[n - 2] + v[n - 1]) / 2.0f64.powf(n as f64 - 1.0);

    for i in 0..n - 2 {
        ans += v[i] / 2f64.powf(i as f64 + 1.0);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
    using namespace std;
     
    string S;
    int N;
     
    void input() {
        cin >> N;
        cin >> S;
    }
     
    void solve() {
        input();
        string tmp = "No";
        int K = N / 2;
        if(N % 2 == 0 && S.substr(0, K) == S.substr(K, K)) tmp = "Yes";
        cout << tmp << endl;
        return;
    }
     
    int main() {
        solve();
        return 0;
    }

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _0011
{
    class Program
    {
        static void Main(string[] args)
        {
            int w = int.Parse(Console.ReadLine());
            int[] kuji = new int[w + 1];
            for (int i = 1; i <= w; i++)
            {
                kuji[i] = i;
            }
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                int[] x = Console.ReadLine().Split(',').Select(int.Parse).ToArray();
                int a = kuji[x[0]];
                kuji[x[0]] = kuji[x[1]];
                kuji[x[1]] = a;
            }
            for (int i = 1; i <= w; i++)
            {
                Console.WriteLine(kuji[i]);
            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9492
n,x=map(int,input().split())

a=[int(i) for i in input().split()]

a.sort()
i=0
ans=0

while x>0 and i<n:
    if x-a[i]>=0:
        x-=a[i]
        ans+=1
    else:
        x=0
    if i==n-1:
        if x>0:
            ans-=1
    i+=1

print(ans)

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

int n;
int a[300010];
long long ans;
long long x[100010], y[100010];

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<3*n; ++i)
		cin >> a[i];
	priority_queue<int, vector<int>, greater<int> > pq;
	long long tmp = 0ll;
	for(int i=0; i<n; ++i){
		pq.push(a[i]);
		tmp += a[i];
	}
	x[0] = tmp;
	for(int i=n; i<2*n; ++i){
		if(pq.top() < a[i]){
			pq.push(a[i]);
			tmp += a[i];
			tmp -= pq.top();
			pq.pop();
		}
		x[i-n+1] = tmp;
	}
	priority_queue<int> q;
	tmp = 0ll;
	for(int i=2*n; i<3*n; ++i){
		q.push(a[i]);
		tmp += a[i];
	}
	y[n+1] = tmp;
	for(int i=2*n-1; i>=n; --i){
		if(q.top() > a[i]){
			q.push(a[i]);
			tmp += a[i];
			tmp -= q.top();
			q.pop();
		}
		y[i-n+1] = tmp;
	}
	ans = -1e18-9;
	for(int i=0; i<n+1; ++i)
		ans = max(ans, x[i] - y[i+1]);
	cout << ans << "\n";
//	for(int i=0; i<n+2; ++i)
//		cout << x[i] << " " << y[i] << "\n";
}

Measured memory_bytes: 3832
#include <cstdio>

int main()
{
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    if (a * b >= c)
    {
        printf("%d", c);
    }
    
    else if (a * b < c)
    {
        printf("%d", a * b);
    }

}


Measured memory_bytes: 1700
#include "bits/stdc++.h"
using namespace std;
//include "dkp.h"
#define foreach(it,a)		for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define rep(i,a,b)			for(int i=(a),_ed=(b);i<_ed;i++)
#define boost				ios_base::sync_with_stdio(0);cin.tie(0);
#define v(T)				vector<T>
#define p(T1, T2)			pair<T1, T2>
#define m(T1, T2)			map<T1, T2>
#define ll					long long int
#define sz(a)				(int) a.size()
#define ms(s, n) 			memset(s, n, sz(s))
#define mp					make_pair
#define pb					push_back
#define ff					first
#define ss					second
#define all(a)				a.begin(), a.end()
#define uni(a)				(a).erase(unique(all(a)), (a).end())
const int inf = 1001001001, mod = (int)1e9+7;
const ll llinf = 1e18;
const double eps = 1e-10, pi = acos(-1.0);
//....................//....................dkp....................//....................//
int n, m;
#define maxm 200002
v(v(int)) graph(maxm);
v(bool) seen(maxm);
v(int) cost(maxm, inf);
int levels=0;
int dfs(int node, int par = -1){
	levels++;
	if(node == n){
		if(levels>2)
			cout << "IMPOSSIBLE" << endl;
		else
			cout << "POSSIBLE" << endl;
		exit(0);
	}
	for(auto next : graph[node]){
		if(next == par)
			continue;
		dfs(next, node);
	}
cout << "IMPOSSIBLE" << endl;
exit(0);
}
int main(){
	cin >> n >> m;
	graph.clear();
	int u, v;
	while(m--){
		cin >> u >> v;
		graph[u].pb(v);
		graph[v].pb(u);
	}
	levels = 0;
	// dfs(1);
	queue<int> q;
	q.push(1);
	seen[1] = 1;
	cost[1] = 0;
	while(!q.empty()){
		int one = q.front();
		q.pop();
		// levels++;
		for(int next : graph[one]){
			if(next == n){
			}
			if(!seen[next]){
				seen[next] = 1;
				cost[next] = min(cost[next], cost[one]+1);	
				q.push(next);
			}
		}
	}
	if(cost[n] > 2){
		cout << "IMPOSSIBLE" << endl;
	}
	else{
		cout << "POSSIBLE" << endl;
	}
return 0;
}

Measured memory_bytes: 13168
#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; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

string s;


int main(){
	cin >> s;
	int ans;
	int i;
	for ( i = 0; i <= (1 << 3) - 1; i++) {
		ans = s[0] - '0';
		for (int j = 0; j < 3; j++) {
			if (i & 1 << j) {
				ans += s[j+1] - '0';
			}
			else {
				ans -= s[j + 1] - '0';
			}
		}
		if (ans == 7)
			break;
	}
	string ret; ret+= s[0];
	for (int j = 0; j < 3; j++) {
		if (i & 1 << j) {
			ret += '+';
		}
		else {
			ret += '-';
		}
		ret += s[j + 1];
	}
	ret += "=7";
	cout << ret << endl;
	return 0;
}


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

int main() {
 i64 N, K;
  cin >> N >> K;
 
  i64 x = N % K;
  if (x < abs(x - K)){
    cout << x << endl;
  }else {
    
    cout << abs(x - K) << endl;
  }
  
  
}

Measured memory_bytes: 256
#include <stdio.h>

int judge(char A[], char B[]){
  int a=0, b=0, sw=0, ans=0;
  int i, j;
  int C[1001][1001];
  
  while(sw == 0){
    if(A[a] != '\0')
      a++;
    else
      sw = 1;
  }
  
  sw = 0;
  
  while(sw == 0){
    if(B[b] != '\0')
      b++;
    else
      sw = 1;
  }
  
  for(i=1; i<a+1; i++)
    C[i][0] = 0;
  for(i=1; i<b+1; i++)
    C[0][i] = 0;
  
  for(i=1; i<a+1; i++){
    for(j=1; j<b+1; j++){
      if(A[i-1] == B[j-1])
        C[i][j] = C[i-1][j-1] + 1;
      else if(C[i-1][j] >= C[i][j-1])
        C[i][j] = C[i-1][j];
      else
        C[i][j] = C[i][j-1];
      if(ans < C[i][j])
        ans = C[i][j];
    }
  }
  
  return ans;
}

int main(){
  char A[1000], B[1000];
  int n, i;
  
  scanf("%d", &n);
  
  for(i=0; i<n; i++){
    scanf("%s", A);
    scanf("%s", B);
    printf("%d\n", judge(A, B));
  }
  
  return 0;
}

Measured memory_bytes: 6608
#include <stdio.h>

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

int main(void){
  int N,A,B;
  scanf("%d%d%d",&N,&A,&B);

  printf("%d\n",min(N*A,B));

  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void) {

	int a8, b10;
	int x;

	cin >> a8 >> b10;
	x = 10 * b10;
	if( (int)(x * 0.08) > a8 )
		cout << -1 << endl;
	else if(a8 == b10 && a8 >= 4)
		cout << -1 << endl;
	else {
		while (a8 != (int)(x * 0.08)) {
			x++;
		}
		if (b10 == (int)(x * 0.1))
			cout << x << endl;
		else
			cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b);
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 29)
using namespace std;

int main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    if(n >= k) cout << k * x + (n - k) * y << endl;
    else cout << n * x << endl;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli num1 , num2 ;
    cin >> num1 >> num2 ;
    cout << num2 * 2 - num1;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

int main()
{
   string s;
   int count=0;
   cin>>s;
   int size= s.length();
   for(int i=0;i<size/2;i++)
{
    if(s[i]!=s[size-1-i])
    count++;
}
cout<<count;
    return 0;
}


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

using namespace std;

int main(){
    int n,d; cin >> n >> d;

    //二次元配列の宣言
    vector<vector<int>> x(n,vector<int>(d));

    //二次元配列の各値に代入
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            cin >> x[i][j];
        }
    }

    //答えを宣言
    int ans = 0;

    for(int k=0; k<n-1; k++){
        for(int l=k+1; l<n; l++){
            int sum = 0;
            for(int m=0; m<d; m++){
                sum += abs(x[k][m]-x[l][m])*abs(x[k][m]-x[l][m]);
            }
            int a = (int)sqrt(sum);
            if(a*a == sum){
                ans += 1;
            }
        }
    }

    //答えの表示
    cout << ans <<endl;

}


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

using namespace std;

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

    int ans = 1e9;

    for (int i = 0; i <= (int)s.size() - (int)t.size(); ++i) {
        int cur = 0;
        for (int j = 0, p = i; j < (int)t.size(); ++j, p++) {
            cur += t[j] != s[p];
        }

        ans = min(ans, cur);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007

using namespace std;

bool checkArraysEqual(int tab[],int tab2[],int dim) {
  for(int i=0; i<dim ; i++){
    if(tab[i]!=tab2[i]) return 0;
  }
  return 1;
}

int main()
{

  int n,p,q,pos1=0,pos2=0;
  int tab[9],tabb[9],tab3[9];
  int i=1;
  cin>>n;
  for(int i=0;i<n;i++){ cin>>tab[i]; tab3[i]=tab[i]; }
  for(int i=0;i<n;i++){ cin>>tabb[i];  }
  sort(tab3,tab3+n);

  do{
    if(checkArraysEqual(tab,tab3,n)==1)  pos1=i;
    if(checkArraysEqual(tabb,tab3,n)==1) pos2=i;
    i++;
  }while(next_permutation(tab3,tab3+n));

  cout<<abs(pos2-pos1);

  return 0 ;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, l;

    cin >> n >> l;

    int ans = (2 * l + n - 1) * n / 2;

    int x = 9999;

    for (int i = 0; i < n; i++)
    {
        if (abs(x) > abs(l + i))
        {
            x = l + i;
        }
    }

    cout << ans - x << endl;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(1, n-1):
    if min(p[i-1], p[i], p[i+1]) != p[i] and max(p[i-1], p[i], p[i+1]) != p[i]:
       cnt += 1
print(cnt)

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

using namespace std;

int main(void)
{
    unsigned long a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    unsigned long sum1, sum2, ans1, ans2, ans3;
    unsigned long l = min(x, y);
    unsigned long h = max(x, y);

    //lowがcの2パターン
    if(x>y){
    sum1 = l * c * 2 + (h - l) * a;
    ans1 = sum1;
    }
    else if(x<=y){
    sum2 = l * c * 2 + (h - l) * b;
    ans1 = sum2;
    }

    //すべてa,bのパターン
    ans2 = a * x + b * y;

    //すべてcのパターン
    ans3 = c * 2 * h;

    cout << min(ans1, min(ans2, ans3)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
#define MAXSIZE 100000
 
int main(void){
    int n,i,lx,ly,len,ch;
    scanf("%d",&n);
    int t[n+1],grid[n+1][2];
    t[0]=0;
    grid[0][0]=0;
    grid[0][1]=0;
    for(i=1;i<n+1;i++){
        scanf("%d %d %d", &t[i], &grid[i][0], &grid[i][1]);
    }
 
    for(i=0;i<n;i++){
        lx=grid[i+1][0]-grid[i][0];
        ly=grid[i+1][1]-grid[i][1];
        if(lx<0) lx=-lx;
        if(ly<0) ly=-ly;
        len=lx+ly;
        ch=t[i+1]-t[i]-len;
        if(ch<0||ch%2!=0){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 1280
# 行列の積の公式
# Cij = Σ(Aik * Bkj)  (k=1, ...)

n, m, l = gets.chomp.split.map(&:to_i)
A = []
n.times do
    A << gets.chomp.split.map(&:to_i).to_a
end
B = []
m.times do
    B << gets.chomp.split.map(&:to_i).to_a
end

n.times do |i|
    line = []
    l.times do |j|
        cij = 0
        m.times do |k|
            cij += A[i][k]*B[k][j]
        end
        line << cij
    end
    puts line.join(" ")
end


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

int main()
{
    ll N;
    cin >> N;
    ll A[N];
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    ll count = 0;

    for(int i = 0; i < N; i++)
    {
        while(A[i] % 2 == 0)
        {
            A[i] /= 2;
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int t;
int n;
int m;
char a[110][110];
int shu[110];
int len[110];
char s[210];
int f[2100];
int ff[220];
int PIPEI(){
	memset(ff,0,sizeof(ff));
	int w=strlen(s);
	for(int i=0;i<w;i++){
		for(int j=1;j<=n;j++){
			if(len[j]<=i+1){
				int v=1;
				for(int k=0;k<len[j];k++){
					if(s[i-len[j]+1+k]!=a[j][k]){
						v=0;
						break;
					}
				}
				if(v)ff[i+1]=max(ff[i+1],ff[i+1-len[j]]+shu[j]);
			}
		}
	}
	return ff[w];
}
int main(){
	scanf("%d",&n);
	while(n){
		t++;
		for(int i=1;i<=n;i++)scanf(" %s %d",&a[i][0],&shu[i]);
		for(int i=1;i<=n;i++)len[i]=strlen(a[i]);
		scanf(" %s",s);
		m=PIPEI();
//		printf("m=%d\n",m);
		memset(f,30,sizeof(f));
		f[0]=0;
		for(int i=1;i<=n;i++){
			for(int j=shu[i];j<=m;j++){
				f[j]=min(f[j],f[j-shu[i]]+len[i]);
			}
		}
		printf("Case %d: %d\n",t,f[m]);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1224
import java.lang.StringBuilder

fun main(args: Array<String>) {
    val (n,q) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!
    val lr = (1..q).map { readLine()!!.split(" ").map { it.toInt()-1 } }

    val ac = IntArray(n)
    for(i in 1..n-1){
        if(s[i-1]=='A' && s[i]=='C') ac[i]=ac[i-1]+1
        else ac[i]=ac[i-1]
    }
    val ans = lr.map {
        val (l,r)=it
        ac[r]-ac[l]
    }
    println( ans.fold(StringBuilder()){ acc ,i-> acc.appendln(i) } )
}



Measured memory_bytes: 65004
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n, x;
    cin >> n >> x;

    if (x == 1 || x == 2 * n - 1) {
        cout << "No" << endl;
        return 0;
    }

    int ans[2 * n - 1];
    fill(ans, ans+2*n-1, 0);

    ans[n-2] = x-1;
    ans[n-1] = x;
    ans[n] = x+1;

    int count = 1;
    if (x < n) {
        ans[n-3] = x+2;
        ans[n+1] = x+3;
        for (int i = 0; i < 2 * n - 1; i++) {
            if (count == x-1) count = x+4;
            if (ans[i] == 0) {
                ans[i] = count;
                count++;
            }
        }
    } else if (x > n) {
        ans[n - 3] = x - 3;
        ans[n + 1] = x - 2;
        for (int i = 0; i < 2 * n - 1; i++) {
            if (count == x - 3) count = x + 2;
            if (ans[i] == 0) {
                ans[i] = count;
                count++;
            }
        }
    } else if (x == n) {
        for (int i = 0; i < 2 * n - 1; i++) {
            if (count == x-1) count = x+2;
            if (ans[i] == 0) {
                ans[i] = count;
                count++;
            }
        }
    }

    cout << "Yes" << endl;
    for (int i = 0; i < 2*n-1; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 2304
import java.util.*;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int H = sc.nextInt();
		int W = sc.nextInt();
		int d = sc.nextInt();
		char[] c = "RYGB".toCharArray();
		
		for(int i=0; i<H; i++) {
			for(int j=0; j<W; j++) {
				pw.print(d%2==0 ? c[( (i+j)/2/(d/2) + (i-j+W)/2/(d/2)*2)%4]: c[(i+j)%4]);
			}
			pw.println();
		}

		sc.close();
		pw.close();
	}
}

Measured memory_bytes: 25300