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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, q;
  cin >> n >> q;
  
  set<tuple<ll, ll, ll>> up, left;
  pair<ll, ll> upleft = make_pair(n - 1, n - 1);
  
  while (q--) {
    ll tmp, x;
    cin >> tmp >> x;
    if (tmp == 1) {
      if (upleft.second >= x) {
        if (x + 1 <= upleft.second) up.insert(make_tuple(x + 1, upleft.second, upleft.first));
        upleft.second = x - 1;
      }
      else {
        auto it = up.upper_bound(make_tuple(x, 1e9, 1e9));
        if (it == up.begin()) continue;
        it--;
        auto [a, b, c] = *it;
        up.erase(it);
        if (a <= x - 1) up.insert(make_tuple(a, x - 1, c));
        if (x + 1 <= b) up.insert(make_tuple(x + 1, b, c));
      }
    }
    else {
      if (upleft.first >= x) {
        if (x + 1 <= upleft.first) left.insert(make_tuple(x + 1, upleft.first, upleft.second));
        upleft.first = x - 1;
      }
      else {
        auto it = left.upper_bound(make_tuple(x, 1e9, 1e9));
        if (it == left.begin()) continue;
        it--;
        auto [a, b, c] = *it;
        left.erase(it);
        if (a <= x - 1) left.insert(make_tuple(a, x - 1, c));
        if (x + 1 <= b) left.insert(make_tuple(x + 1, b, c));
      }
    }
  }
  
  ll ans = (upleft.first - 1) * (upleft.second - 1);
  for (auto it = up.begin(); it != up.end(); it++) {
    auto [a, b, c] = *it;
    ans += (b - a + 1) * (c - 1);
  }
  for (auto it = left.begin(); it != left.end(); it++) {
    auto [a, b, c] = *it;
    ans += (b - a + 1) * (c - 1);
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 9804
#include <bits/stdc++.h>
using namespace std;
long long inf = numeric_limits<long long>::max();

int main(){
    int N, K;
    cin >> N;
    cin >> K;
    vector<long long> h(N);
 
    for(long long i=0; i<N; i++){
        cin >> h[i];
    }

    // init dp table
    vector<long long> dp(N, inf);
    dp[0] = 0;
    
    for(long long i=1; i<N; i++){
        long long min = inf;
        for(long long j=1; j<K+1; j++){
            // 配列外参照防止
            if(i-j>=0 && i-j<N){
                // cout << i << " " << i-j << endl;
                // cout << min << endl;
                if((dp[i-j] + abs(h[i] - h[i-j])) < min){
                    min = abs(h[i] - h[i-j]) + dp[i-j];
                }
            }
        }
        dp[i] = min;
    }

    // 添字注意．
    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int A,B,C,ans,chuuou;
  cin >> A >> B >> C;
  vector<int> kazu = {A,B,C};
  sort(kazu.begin(),kazu.end());
  chuuou = kazu[1];
  ans = (chuuou - kazu[0]) + (kazu[2] - chuuou);
  cout << ans <<"\n";
}

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

#define ll long long
#define endl '\n'

void max_self(int &a, int b){ a = max(a, b);}
void min_self(int &a, int b){ a = min(a, b);}

void solve(){
	int n, k; cin>>n>>k;
	vector< int > v(n);
	for(int &i : v) cin>>i;
	sort(v.begin(), v.end());
	int ans = 0;
	for(int i = 0; i<k; i++){
		ans += v[i];
	}
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	for(int i = 1; i<=t; i++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3652
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var A = Sarray()[0];
            WriteLine(N * N - A);
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28044
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  ll k,n;
  ll ans[100] = {};
  cin >> k;
  n = 50;

  for(int i=0;i<n;i++){
    ll p;
    if(i < k%n){
      p = k/n + 1;
    }else{
      p = k/n;
    }
    
    ans[i] = (n-1) + n * p - (k - p);
  }

  printf("%lld\n",n);
  for(int i=0;i<n;i++){
    printf("%lld%c",ans[i]," \n"[i ==n-1]);
  }
  
  return 0;
}


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

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

  int outFlag = 0;
  string W[N];
  cin >> W[0];
  for(int i=1;i<N;i++){
    cin >> W[i];
    for(int j=0;j<i;j++){
      if(W[i] == W[j]){
        outFlag = 1;
        break;
      }
    }
    /*
    if(outFlag == 1){
      break;
    }
    */
    if(W[i][0] != W[i-1][W[i-1].length() - 1]){
      outFlag = 1;
      //break;
    }

  }


  if(outFlag == 1){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long N, long long A){
    cout << N * N - A << endl;
}

int main(){

    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    solve(N, A);
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 
 
int main()
{
    fastio();
    lli h,w; cin>>h>>w;
    if(h==1 || w==1) {cout<<1<<endl; return 0;}
    cout<<((w+1)/2)*((h+1)/2)+(w/2)*(h/2);
    return 0;
}

Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;

#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+6;

ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}

// using namespace __gnu_pbds;
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set

int32_t main()
{
IOS

    
    char ch;
    cin>>ch;
    ch++;
    cout<<ch;    
    
}     

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

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int m1 = sc.nextInt();
    int d1 = sc.nextInt();
    int m2 = sc.nextInt();
    int d2 = sc.nextInt();
    if (m1 < 12) {
      if (m1 + 1 == m2) {
        System.out.println(1);
      } else {
        System.out.println(0);
      }
    } else {
      System.out.println(0);
    }
  }
}

Measured memory_bytes: 32716
n,k,*h=map(int,open(0).read().split())

INF=float("inf")
dp=[INF]*(n)
dp[0]=0

for i in range(n):
    for j in range(1,k+1):
        try:
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
        except:
            pass

    # if not i-1<0:
    #     dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    # if not i-2<0:
    #     dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))


print(dp[-1])

Measured memory_bytes: 59948
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int n, pos{0};
vi pre, in, post;
inline void rec(int l, int r) {
	if(l >= r) return;
	int root = pre[pos++];
	int m = distance(in.begin(), find(all(in), root));
	rec(l, m);
	rec(m + 1, r);
	post.eb(root);
}
int main() {
	cin >> n;
	pre.resize(n); in.resize(n); post.reserve(n);
	rep(i, 0, n) cin >> pre[i];
	rep(i, 0, n) cin >> in[i];
	rec(0, len(pre));
	cout << post[0];
	rep(i, 1, n) cout << " " << post[i];
	cout << endl;
	return 0;
}

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

int main(){
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  
  int retval = 0;
  if (2*C < A+B) { // ABピザを買った方がお得
    if (X<Y) { // ABピザを2X枚(A:X枚, B:X枚)、Bを(Y-X)枚
      retval += C*2*X;
      retval += min(B,2*C)*(Y-X);
    }
    else {
      retval += C*2*Y;
      retval += min(A,2*C)*(X-Y);
    }
  }
  else {
    retval += A*X + B*Y;
  }
  
  cout << retval << endl;
    
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,i,j;
  while(1){
    cin >> h >> w;
      if(h==0 && w==0) break;
    for(j=1;j<=h;j++){
      for(i=1;i<=w;i++){
	if(j==1 || j==h){
	  cout << '#';
	}else{
	  if(i==1 || i==w) cout << '#';
	  else  cout << '.';
	}
      }
      cout << endl;
    }
    cout <<endl;
  }
  return 0;
}





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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

bool solve(int n, int A[], int m, int idx) {
  if(m == 0) return true;
  if(m < 0) return false;
  reps(i, idx, n) {
    if(solve(n, A, m-A[i], i+1)) return true;
  }
  return false;
}

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

  int n, A[22], q, m[202];
  cin >> n;
  rep(i, n) cin >> A[i];
  cin >> q;
  rep(i, q) cin >> m[i];
  rep(i, q) {
    if(solve(n, A, m[i], 0)) cout << "yes" << endl;
    else cout << "no" << endl;
  }

  return 0;
}

Measured memory_bytes: 3216
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, t string
	fmt.Scan(&n)
	fmt.Scan(&t)

	ns := strings.Split(n, "")
	ts := strings.Split(t, "")

	cnt := 0
	for i, n := range ns {
		if n == ts[i] {
			cnt++
		}
	}

	fmt.Print(cnt)
}


Measured memory_bytes: 640
awk 'NR == 1 {
  n = $1
  k = $2
}
NR == 2 {
  r = $1
  s = $2
  p = $3
}
NR == 3 {
  t = $0
  ans = 0
  for (i=1; i<=k; ++i) {
    last = ""
    for (j=i; j<=n; j += k) {
      c = substr(t, j, 1)
      if (c == "r" && last != "p") {
        last = "p"
        ans += p
      } else if (c == "p" && last != "s") {
        last = "s"
        ans += s
      } else if (c == "s" && last != "r") {
        last = "r"
        ans += r
      } else {
        last = j
      }
    }
  }
  print ans
}'


Measured memory_bytes: 808
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL rou(LL a,LL d){if((a*10/d)%10<5)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}

int main(){
  LL N,M,i,ans=0;
  scanf("%lld%lld",&N,&M);

  if(N==M)printf("Yes\n");
  else printf("No\n");
  //printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;
int num=0;
void check(int n){
  if(n==1)
    return;
  if(n%2==0){
    check(n/2);
    num++;
  }else{
    check((n*3)+1);
    num++;
  }
}
int main(){
  int n;
  while(cin>>n,n!=0){
    num=0;
    check(n);
    cout<<num<<endl;
  }
  return 0;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

static string S;
static vector<int> memo;

// recursive
static int lastpos(int pos);

static int
calcpos(int pos)
{
  int oldpos = pos;
  pos += (S[pos] == 'R' ? 1 : -1);
  pos += (S[pos] == 'R' ? 1 : -1);
  return pos == oldpos ? pos : lastpos(pos);
}

static int
lastpos(int pos)
{
  if (memo[pos] == 0)
  {
    memo[pos] = calcpos(pos) + 1;
  }
  return memo[pos] - 1;
}

int
main()
{
  cin >> S;
  vector<int> C(S.size());
  memo.resize(S.size());
  for (int i = 0; i < S.size(); i++)
  {
    C[lastpos(i)]++;
  }
  bool first = true;
  for (int c : C)
  {
    if (first)
    {
      first = false;
    }
    else
    {
      cout << ' ';
    }
    cout << c;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
using namespace std;
 
 
int main(){
    int n,m; cin >> n >> m;
    ll ans=0;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    vector<P> ko(m);
    rep(i,m){
        int b,c; cin >> b >> c;
        ko[i].second=b; ko[i].first=c;
    }
    sort(all(ko));
    int now=0;
    rep(i,n){
        if(ko.empty() || a[i]>=ko.back().first){
            ans+=a[i];
            continue;
        }
        ans+=ko.back().first;
        ko.back().second--;
        if(ko.back().second==0) ko.pop_back();
    }
  cout << ans << endl;
return 0;
}

Measured memory_bytes: 2304
A,B=map(int,input().split())
if A>B+1:
  print(A+A-1)
elif A-1==B:
  print(A+B)
elif B>A+1:
  print(B+B-1)
elif B-1==A:
  print(A+B)
else:
  print(A+B)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

const int mxN = 1e5;

void solve(){
	int n,k; string s; cin >> n >> k >> s;
	
	vector<int> seg0, seg1;
	
	// find lengths of all 0 segments and 1 segments
	int zeros = 0, ones = 0;
	int cnt = 0;
	for(char c : s){
		++cnt;
		if(c == '0' && cnt == s.size()) seg0.pb(zeros+1);
		else if(c == '0') ++zeros;
		else if(zeros) seg0.pb(zeros), zeros = 0;
		
		if(c == '1' && cnt == s.size()) seg1.pb(ones+1);
		else if(c=='1') ++ones;
		else if(ones) seg1.pb(ones), ones = 0;
	}
	
	//debugv(seg0);
	//debugv(seg1);
		
	while(seg0.size() < mxN) seg0.pb(0);
	while(seg1.size() < mxN) seg1.pb(0);
	
	int fin_ans = 0, cur_ans = 0;
	
	// if we start with 0 segment
	if(s[0] == '0'){
		FOR(k) cur_ans += seg0[i] + seg1[i];
		fin_ans = cur_ans;
		FOR(i,k,(1e5)/2 + 7){
			int low0 = i-k;
			int low1 = i-k-1;
			// guarantee low1 to be 0
			if(low1 == -1) low1 = 1e5 - 1; 
			cur_ans += seg0[i] + seg1[i] - seg0[low0] - seg1[low1];
			fin_ans = max(fin_ans, cur_ans);
		}
	} else{
		FOR(k) cur_ans += seg0[i] + seg1[i];
		cur_ans += seg1[k];
		fin_ans = cur_ans;
		FOR(i,k,(1e5)/2 + 7){
			int high0 = i;
			int high1 = i+1;
			int low0 = i-k;
			int low1 = i-k;
			cur_ans += seg0[high0] + seg1[high1] - seg0[low0] - seg1[low1];
			fin_ans = max(fin_ans, cur_ans);
		}
	}
	
	cout << fin_ans;
}
 
 
 //5 1
//00010

//seg0: 3 1 0 0 

//seg1: 1 0 0 0
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 4452
#include <bits/stdc++.h>
using namespace std;
int n, A[30];
bool solve(int i, int m) {
  if (m == 0) return true;
  if (i >= n) return false;
  return solve(i + 1, m) || solve(i + 1, m - A[i]);
}
int main() {
  int t, M;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    scanf("%d", &M);
    if (solve(0, M))
      printf("yes\n");
    else
      printf("no\n");
  }
  return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {
    int n, a;
    vector<int> as;
    long sum = 0;
    cin >> n;
    
    REP(i,n) {
        cin >> a;
        sum += a;
        as.push_back(a);
    }
    
    int k = int(sum * 2 / n / (n + 1));
    int tmp = as[n-1];
    for (int i = n - 1; i >= 1; i--) {
        as[i] -= as[i-1];
    }
    as[0] -= tmp;
    
    REP(i,n) as[i] -= k;
    bool flag = k > 0 && sum % k == 0;
    int flagcnt = 0;
    REP(i,n) {
        if (as[i] != 0) {
            if (as[i] > 0) {
                flag = false;
            }
            if (as[i] % n != 0) {
                flag = false;
            } else {
                flagcnt += (-1 * as[i] / n);
            }
        }
    }
    
    if (flag && flagcnt == k) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 892
#include <iostream>

using namespace std;

int n, k;
int d[101], a[101][101], fr[101];
int main() {
    cin >> n >> k;

    for (int i = 1; i <= k; i++) {
        cin >> d[i];
        
        for(int j = 1; j <= d[i]; j++) {
            cin >> a[i][j];
            fr[a[i][j]]++;
        }

    }

    int ans = 0;
    for(int i = 1; i <= n; i++) {
        if(fr[i] == 0)
            ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int x = 0;
    int y = 0;
    for(int i = 0; i < s.length(); i++)
    {
        if(i%2==0)
        {
            if(s[i]!='0')
            {
                x++;
            }
            else
            {
                y++;
            }
        }
        else
        {
            if(s[i]!='0')
            {
                y++;
            }
            else
            {
                x++;
            }
        }
    }
    int ans = min(x,y);
    cout << ans << endl;
    return 0;
}


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

int main(){
    int x,y;
    cin>>x>>y;
    int r;
    int ans;
    while(true){
        r=x%y;
        if(r==0){
            ans=y;
            break;
        }
        x=y;
        y=r;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long int ll;
typedef string str;

int main ()
{
	ll t,n,m,k,i,j,a,b;
	cin >> n;
	ll arr[n+2],h[2*n+3]={0},h1[2*n+3]={0};
	for(i=1;i<=n;i++)
	{
		cin >> arr[i];
		a=arr[i]+i;
		b=i-arr[i];
		if(a<=2*n)
			h[a]++;
		if(b>=2)
			h1[b]++;
	}
	k=0;
	for(i=2;i<=2*n;i++)
	{
		k+=h1[i]*h[i];
	}
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 11432
#include <iostream>
using namespace std;
//H * Wの長方形を出力する
int main(){
	int H, W;
	while(cin >> H >> W){
		if(H == 0 && W == 0) return EXIT_SUCCESS;
		for(int y = 0; y < H; y++){
			for(int x = 0; x < W; x++){
				cout << '#';
			}
			cout << '\n';
		}
		cout << '\n';
	}
}



Measured memory_bytes: 3068
#include <iostream>
#include <cstdlib>
#include <vector>

int main()
{
   int N;
   std::cin >> N;
   std::vector<int> A;
   A.reserve(N);
   std::cin.ignore();
   
   //bool dupicateMax = false;
   int max = 0;
   int second = 0;
   int n = N;
   while(n-->0) {
    int a;
    std::cin >>a;
    std::cin.ignore();
    if(a >max) {
        second = max;
        max = a;
        //second = max;
    //    duplicateMax = false;
    } else if(a == max) {
     //   duplicateMax = true;
        second = max;
    } else if( a > second) {
        second = a;
    }
    A.push_back(a);
   }
   for(int i = 0; i<N;++i) {
    if(A[i]==max ) {
        std::cout<< second << std::endl;
    } else {
        std::cout<< max << std::endl;
    }
   }
}

Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;

int main() {
  int n;
  cin>>n;
  vector<int> l(n);
  rep(i,0,n)cin>>l[i];
  sort(l.begin(),l.end(),greater<int>());
  int sum=0;
  rep(i,1,n)sum+=l[i];
  if(l[0]<sum)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<string>
#include<vector>
#include<cstring>
#include<iostream>

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

using namespace std;

const int M=1000000007;

struct edge{
	int u,v,id;
	string s;
};

int n1,n2;
edge E1[600],E2[600];
vector<int> adj1[500],adj2[500];

int dp[600][600][6];
int dfs(int i1,int i2,int p1,int p2){
	int dummy,&res=(p1==0?dp[i1][i2][p2]:dummy);
	if(p1==0 && ~res) return res;

	// 2 ÂÌ|C^ª¯É DAG ÌI[É½
	if(p1==E1[i1].s.length() && p2==E2[i2].s.length()){
		int v1=E1[i1].v,v2=E2[i2].v;
		if(v1==n1-1 && v2==n2-1) return res=1;
	}

	// |C^ 1 ª¶ñI[É½
	if(p1==E1[i1].s.length()){
		int v=E1[i1].v,cnt=0;
		rep(k,adj1[v].size()) cnt=(cnt+dfs(adj1[v][k],i2,0,p2))%M;
		return res=cnt;
	}

	// |C^ 2 ª¶ñI[É½
	if(p2==E2[i2].s.length()){
		int v=E2[i2].v,cnt=0;
		rep(k,adj2[v].size()) cnt=(cnt+dfs(i1,adj2[v][k],p1,0))%M;
		return res=cnt;
	}

	// wµÄ¢é¶ªá¤ÈçTõÅ¿Øè
	if(E1[i1].s[p1]!=E2[i2].s[p2]) return res=0;

	return res=dfs(i1,i2,p1+1,p2+1);
}

int main(){
	int T; cin>>T;
	while(T--){
		memset(dp,-1,sizeof dp);
		int m1; cin>>n1>>m1;
		rep(u,n1) adj1[u].clear();
		rep(j,m1){
			int u,v;
			string s; cin>>u>>v>>s;
			adj1[u].push_back(j);
			E1[j]=(edge){u,v,j,s};
		}
		int m2; cin>>n2>>m2;
		rep(u,n2) adj2[u].clear();
		rep(j,m2){
			int u,v;
			string s; cin>>u>>v>>s;
			adj2[u].push_back(j);
			E2[j]=(edge){u,v,j,s};
		}

		int ans=0;
		rep(i,adj1[0].size()) rep(j,adj2[0].size()) {
			ans=(ans+dfs(adj1[0][i],adj2[0][j],0,0))%M;
		}
		printf("%d\n",ans);
	}

	return 0;
}

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

int main(void){
  int N; 
  cin>>N;
  
  int l,r;
  int ans = 0;
  rep(i,0,N){
    cin >>l>>r;
    ans += r-l+1;
  }
  
  cout <<ans<< endl;
}

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

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

    int x_max = -101, y_min = 101;
    for (int i = 0; i < n; i++)
    {
        int _x;
        cin >> _x;

        x_max = max(x_max, _x);
    }

    for (int i = 0; i < m; i++)
    {
        int _y;
        cin >> _y;

        y_min = min(y_min, _y);
    }

    if (x_max < y_min && x_max < y && x < y_min && x < y) {
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def dfs(c,lst):
 n=len(lst)
 ans=[0]*n
 stack = [c-1]
 check = [0]*n #チェック済みリスト
 while stack != [] :
  d=stack.pop()
  if check[d]==0:
   check[d]=1
   for i in lst[d]:
    if check[i]==0:
     stack.append(i)
     ans[i]=ans[d]+1
 return(ans)
import sys
input = sys.stdin.readline
N,u,v=map(int,input().split())
ki=[[] for f in range(N)]
for i in range(N-1):
 a,b = map(int,input().split())
 ki[a-1].append(b-1)
 ki[b-1].append(a-1)
U=dfs(u,ki)
V=dfs(v,ki)
ans=0
for i in range(N):
 if V[i]>U[i]:
  ans=max(ans,V[i]-1)
print(ans)


Measured memory_bytes: 61752
#include <string>
#include <iostream>

const unsigned int JISHOMAX=20000000;

int array(char data)
{
  data -= 0x40;
  if (data == 1) return 1;
  if (data == 3) return 2;
  if (data == 7) return 3;
  return 4;
}

int get_hashkey(char *data)
{
  int dig = 1, i = 0, sum=-1;
  for (i=0; data[i] != '\0';i++)
  {
    sum += array(data[i])*dig;
    dig *= 4;
  }

  return sum; 
}


int main()
{
  char *jisho = new char[JISHOMAX];

  int n;
  std::cin >> n;

  for (int i=0; i<n; i++)
  {
    char order[7], mes[13];
    std::cin >>order >> mes;
    
    if (order[0] == 'i') jisho[get_hashkey(mes)] = 'Y';
    else 
    {
      if (jisho[get_hashkey(mes)] == 'Y')
        std::cout <<"yes"<<std::endl;
      else
        std::cout <<"no"<<std::endl;

    }
  }
}



Measured memory_bytes: 4468
#include<iostream>
#define N 8
using namespace std;
int usedcol[N], usedrow[N], usedlowl[2*N-1], usedlowr[2*N-1];
void rec(int cnt) {
  if (cnt == N) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j)
	cout << (usedrow[i] == j ? 'Q' : '.');
      cout << endl;
    }
    return;
  }
  if (usedrow[cnt] != -1) rec(cnt + 1);
  else{
    for (int i = 0; i < N; ++i) {
      if (usedrow[cnt] == -1 && usedcol[i] == -1 && usedlowl[cnt + i] == -1 && usedlowr[N - 1 + cnt - i] == -1) {
	usedrow[cnt] = i;
	usedcol[i] = cnt;
	usedlowl[cnt + i] = usedlowr[N - 1 + cnt - i] = 1;
	rec(cnt + 1);
	usedrow[cnt] = usedcol[i] = usedlowl[cnt + i] = usedlowr[N - 1 + cnt - i] = -1;
      }
    }
  }
}
int main() {
  int n; cin >> n;
  for (int i = 0; i < N; ++i) usedrow[i] = usedcol[i] = -1;
  for (int i = 0; i < 2 * N - 1; ++i) usedlowl[i] = usedlowr[i] = -1;
  for (int i = 0; i < n; ++i) {
    int x, y; cin >> y >> x;
    usedrow[y] = x;
    usedcol[x] = y;
    usedlowl[x + y] = usedlowr[N - 1 + y - x] = 1;
  }
  rec(0);
  return 0;
}



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

#define int long long

signed main(){

    int n, k; cin >> n >> k;
    int x = 0;
    for(int i = 0; i < n - 1; i++){
        x = k * (x / (k - 1)) + x % (k - 1) + 1;
    }

    cout << x << endl;
    return 0;
}


Measured memory_bytes: 3124
L = sorted(list(map(int, input().split())),reverse=True)

x = L[0]-L[1]
y = L[0]-L[2]
count = 0

while x!= 0 or y != 0:
    if (x+y)%2 == 1:
        y += 1
        count += 1
    if x%2 == 0 and x>0:
        x -= 2
        count += 1
    elif y%2 == 0 and y>0:
        y -= 2
        count += 1
    elif x%2 == 1 and y%2 == 1:
        x -= 1
        y -= 1
        count += 1
    else:
        break
print(count)

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

int main()
{
    int n;
    cin >> n;
    vector<int> S(n);
    for (int i = 0; i < n; i++)
    {
        cin >> S[i];
    }
    int m;
    cin >> m;
    vector<int> T(m);
    for (int i = 0; i < m; i++)
    {
        cin >> T[i];
    }

    int ans = 0;
    for (int i = 0; i < T.size(); i++)
    {
        for (int j = 0; j < S.size(); j++)
        {
            if (S[j] == T[i])
            {
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

using namespace std;

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

    char c;
    cin >> c;
    cout << (c >= 'a' ? 'a' : 'A');
    
    return 0;
}

Measured memory_bytes: 3604
package main

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

var sc *bufio.Scanner
var out *bufio.Writer

func main() {
	sc = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n := nextInt()

	result := "Yes"
	if n < 30 {
		result = "No"
	}

	fmt.Fprintln(out, result)
}

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


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

int main()
{
    int n, min{1000}, sum{};
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        int s;
        scanf("%d", &s);
        if (s % 10 && s < min) min = s;
        sum += s;
    }
    if (sum % 10) printf("%d\n", sum);
    else if (min != 1000) printf("%d\n", sum - min);
    else printf("0\n");

    return 0;
}

Measured memory_bytes: 256
li = list(map(int, input().split(' ')))
w = li[0]
h = li[1]
x = li[2]
y = li[3]
r = li[4]

if x - r < 0:
    print('No')
elif y - r < 0:
    print('No')
elif x + r > w:
    print('No')
elif y + r > h:
    print('No')
else:
    print('Yes')



Measured memory_bytes: 5596
//go:generate echo "https://atcoder.jp/contests/abc174/tasks/abc174_a"
package main

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

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) Ints(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func solve(X int) bool {
	return X >= 30
}

func main() {
	scan := newScanner(os.Stdin)
	X := scan.Int()
	if solve(X) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1772
import java.util.Scanner;

public class Main {

	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		String S=sc.next();
		
					if(S.charAt(2)==(S.charAt(3)) && S.charAt(4)==(S.charAt(5))){
						System.out.println("Yes");
					}else{
						System.out.println("No");
					}
			}
}


Measured memory_bytes: 24148
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;

Node treeSearch(Node u,int k){
  while((u != NIL) && (k != u->key)){
    if(k < u->key){
      u = u->left;
    }
    else {
      u = u->right;
    }
  }
  
  return u;
}

void Insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else {
      x = x->right;
    }
  }
  z->parent = y;
  
  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else {
    y->right = z;
  }
}

void Inorder(Node u){
  if(u->left != NIL){
    Inorder(u->left);
  }
  printf(" %d",u->key);
  
  if(u->right != NIL){
    Inorder(u->right);
  }
}

void Preorder(Node u){
  printf(" %d",u->key);
  if(u->left != NIL){
    Preorder(u->left);
  }
  if(u->right != NIL){
    Preorder(u->right);
  }
}

int main(){
  int n, i, x;
  char com[20];
  Node t;
  
  scanf("%d", &n);
  
  root = malloc(sizeof(struct node));
  root = NIL;
  
  for (i = 0 ; i < n ; i++){
    scanf("%s", com);
    
    if (com[0] == 'f'){
      scanf("%d", &x);
      t = treeSearch(root, x);
      if (t != NIL) printf("yes\n");
      else printf("no\n");
    } 
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      Insert(x);
    } 
    else if ( com[0] == 'p' ){
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    } 
  }
  
  return 0;
}

Measured memory_bytes: 9844
using System;
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine();
            if (r[0] == r[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }


        
    }
}

Measured memory_bytes: 13140
import math


def next_sunuke(N):
    D = math.ceil(math.log(N, 10) + 1)
    z = str(N)
    zx = [int(z[:1]) for z in z]
    Z = N / sum(zx)
    ret_val = N
    ret_vals = [ret_val]
    for d in range(0, D):
        x = ((10 ** (d + 1)) * math.floor((N / (10 ** (d + 1))) + 1)) - 1
        w = str(x)
        sx = [int(w[:1]) for w in w]
        y = x / sum(sx)
        if y == Z:
            Z = y
            ret_vals.append(x)
        elif y < Z:
            Z = y
            ret_vals = []
            ret_vals.append(x)
    return min(ret_vals)


K = int(input())
n = 1
for i in range(1, K + 1):
    print(next_sunuke(n))
    n = next_sunuke(n) + 1


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
const int MOD = 1000000007;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;

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

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>

#define rep0(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rep1(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)

using namespace std;

int N;

int main(void)
{
	cin >> N;

	int cnt;

	if (N%2==0) 
	{
		cout << N << endl;
	}
	else 
	{
		cout << 2 * N << endl;
	}

	



	return 0;
}

Measured memory_bytes: 256
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

	int a;cin>>a>>a;
	string s;
	cin>>s;
	s[a-1]=tolower(s[a-1]);
	cout<<s<<endl;
}


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

using namespace std;

long long MAX = pow(10, 18);


int main()
{
    int a;
    unsigned long long output = 1;
    cin >> a;
    bool right = true;
    for (int i = 0; i < a; i++) {
        unsigned long long temp;
        cin >> temp;
        unsigned long long form = output;
        output = output * temp;
        if (temp != 0 && output / temp != form) {
            right = false;
        }
        if (output > MAX) {
            right = false;
        }
        if (temp == 0) {
            right = true;
        }
    }
    if (!right) {
        cout << -1;
    }
    else {
        cout << output;
    }


    return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int Sum10(int n);

int main()
{
    // 入力
    string S;
    cin >> S;
    int K;
    cin >> K;
    char ans = '1';
    for (int i=0;i<K;i++){
        if(S[i]!='1'){
            ans = S[i];
            break;
        }
    }
    cout << ans <<endl;
    return 0;
}

int Sum10(int n){
    int sum = 0;
    while (n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}


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

A = sorted(A)
A = [i for i in A if i % 2 == 0]

a = 0
cnt = 0


while True:
    A = [i / 2 for i in A]
    a += 1
    cnt += a*len([i for i in A if i % 2 == 1])

    if len([i for i in A if i > 1]) == 0:
        break
    A = [i for i in A if i % 2 == 0]
print(cnt)


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

int main() {
  int n;
  cin >>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  int kotae=INT_MAX;
  int sum=0;
  for(int j=a[0];j<=a[n-1];j++){
    sum=0;
    for(int i=0;i<n;i++){
      sum+=(j-a[i])*(j-a[i]);
    }
    kotae=min(kotae,sum);
  }
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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;
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int d; cin >> d;
    vector<int> c(26);
    rep(i,0,26) cin >> c[i];
    vector<vector<ll>> s(d,vector<ll>(26));
    rep(i,0,d){
        rep(j,0,26){
            cin >> s[i][j];
        }
    }
    vector<int> t(d);
    rep(i,0,d){
        cin >> t[i];
        t[i]--;
    }
    ll m = 0ll;
    vector<int> past(26,0);
    rep(i,0,d){
        past[t[i]] = i+1;
        rep(j,0,26){
            m -= c[j]*(i+1-past[j]);
        }
        m += s[i][t[i]];
        cout << m << endl;
    }
}

Measured memory_bytes: 3664
package main

import "fmt"

func main() {
	var k int
	var mat = make([]int, 5)
	for i := range mat {
		fmt.Scan(&mat[i])
	}
	fmt.Scan(&k)

	for i := 0; i < len(mat); i++ {
		for j := i + 1; j < len(mat); j++ {
			if mat[j]-mat[i] > k {
				fmt.Println(":(")
				return
			}
		}
	}
	fmt.Println("Yay!")
}


Measured memory_bytes: 512
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let (n, m): (usize, usize) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        let mut ws = s.split_whitespace();
        let a = ws.next().unwrap().parse().unwrap();
        let b = ws.next().unwrap().parse().unwrap();
        (a, b)
    };

    let mut vec = {
        let mut x: Vec<Vec<isize>> = Vec::new();
        for _ in 0..n {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let s = s.trim_right().to_owned();
            let v_i = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
            x.push(v_i);
        }
        x
    };

    let mut max = std::isize::MIN;
    for i in 0..8 {
        let signs = vec![sign(i, 0), sign(i, 1), sign(i, 2)];

        vec.sort_by(|a, b| (sum(a, &signs)).cmp(&sum(b, &signs)));
        vec.reverse();
        let sum: isize = vec[0..m].iter().map(|item| sum(item, &signs)).sum();
        if max < sum {
            max = sum;
        }
    }
    println!("{}", max);
}

fn sign(bits: usize, i: usize) -> isize {
    if bits & (1 << i) > 0 {
        1
    } else {
        -1
    }
}

fn sum(item: &Vec<isize>, sign: &Vec<isize>) -> isize {
    item.iter().zip(sign.iter()).map(|(a, s)| a * s).sum()
}


Measured memory_bytes: 4352