akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	int  r = scanner.nextInt();
	  	int  c = scanner.nextInt();
	  	int[][] array;//配列確保
        array = new int[r + 5][c + 5];
        
        //初期化
        for (int i = 0; i <= r; i++) {
        	for (int j = 0; j <= c; j++) {
        		array[i][j] = 0;
	        }
        }
        // データ入力
        for (int i = 0; i < r; i++) {
        	for (int j = 0; j < c; j++) {
        		array[i][j] = scanner.nextInt();
	        }
        }
        
        // データ補完
        for (int i = 0; i <= r; i++) {
        	for (int j = 0; j <= c; j++) {
	            if( j < c ) {
	            	array[i][c] += array[i][j];
	            }
		            
	            if( i < r ) {
	            	array[r][j] += array[i][j];
	            }

	            if( i == r && j == c )
	        	  	array[r][c] /= 2;
	            
        	}
        }
        
        for (int i = 0; i <= r; i++) {
        	for (int j = 0; j <= c; j++) {
	            if( j == c && i < r )
        			System.out.println(array[i][j] );
	            else if( j == c && i == r )
        			System.out.println(array[i][j]);
	            else
        			System.out.print(array[i][j] + " ");
	        }
        }
        scanner.close();
  }
}


Measured memory_bytes: 42356
using System;
using System.Collections.Generic;


public class Contest
{
	public static void Main()
	{
		int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));

//		int[] b = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] c = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] d = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
/*
		int n = a[0];
		int[][] e = new int[n][];
		for(int i=0; i<n; i++) e[i] = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
*/



		string ans = (a[0]+a[1]/2).ToString();

		Console.WriteLine(ans);
	}
	
	private static int calc_main(int[] a,int[] b,int[] c,int[] d) {



		return 0;
	}




}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

vector<ll> L;

ll getP(int N, ll X) {
    if (N == 0) {
        if (X > 0) {
            return 1;
        } else {
            return 0;
        }
    }

    if (X <= 0) {
        return 0;
    } else if (X >= L[N]) {
        return 1 + 2 * getP(N - 1, L[N - 1]);
    } else if (X >= L[N - 1] + 2) {
        return getP(N - 1, L[N - 1]) + 1 + getP(N - 1, X - 2 - L[N - 1]);
    } else if (X >= 1) {
        return getP(N - 1, X - 1);
    }
}

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

    L.resize(N + 1);
    L[0] = 1;
    for (int i = 1; i <= N; i++) {
        L[i] = 2 * L[i - 1] + 3;
    }
    cout << getP(N, X) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<utility>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    sort(a.rbegin(), a.rend());
    ll ans = 0;
    int t = n-1;
    for(int i = 0; i < n; i++){
        int lim = 2;
        if(i == 0) lim = 1;

        for(int j = 0; j < lim; j++){ //最初以外は一つにつき2回使える
            if(t > 0){
                ans += a[i];
                t--;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4068
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    int n;
    while(cin>>n){
        int ans=n%39!=0?n%39:39;
        printf("3C%02d\n",ans);
    }
    
    return 0;
}

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

namespace ABC149B
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABK = ReadLong();
            long A = ABK[0];
            long B = ABK[1];
            long K = ABK[2];

            long a, b;

            if (K <= A)
            {
                a = A - K; b = B;
            }
            else
            {
                a = 0; b = A + B - K;
            }
            if (b < 0) b = 0;

            Console.WriteLine(a + " " + b);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int h, w, m, r, c, ans = 0;
    cin >> h >> w >> m;
    vector<int> hei(h+1), wid(w+1), cr, cc;
    set<pair<int, int>> store;
    for (int i=0; i<m; i++){
        cin >> r >> c;
        hei[r]++, wid[c]++;
        store.insert({r, c}) ;
    }
    int mh = *max_element(hei.begin(), hei.end()), mw = *max_element(wid.begin(), wid.end());
    for( int i=1; i<=h; i++)
        if (hei[i]==mh)
            cr.emplace_back(i);
    for (int i=1; i<=w; i++)
        if (wid[i]==mw)
            cc.emplace_back(i);
    ans = mh+mw-1;
    for (auto &i: cr) {
        bool tob= false; 
        for (auto &j: cc) {
            if (store.find({i, j}) == store.end()) {
                ans++;
                tob = true; 
                break;
            }
        }
        if (tob) break; 
    }
    cout << ans << "\n";
}

Measured memory_bytes: 23812
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int MAXN = 200100;
const ll MOD = 998244353;

int N;
string X;
vector <int> pfac;
ll rv[MAXN];

ll gogo (int K)
{
    ll cv = 0;
    for (int i = 0; i < K; i++)
        cv = (2 * cv + (X[i] - '0')) % MOD;
    if (K == N) cv++;
    for (int i = K; i < N; i++)
    {
        int ov = 1 - (X[i-K] - '0');
        int nv = X[i] - '0';
        if (ov > nv)
        {
            break;
        }
        else if (ov < nv)
        {
            cv++;
            break;
        }
        else if (i == N - 1)
        {
            cv++;
            break;
        }
    }
    cv %= MOD;
    return cv;
}

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N;
    cin >> X;

    for (int i = 1; i <= N; i++)
    {
        if (N % i == 0)
        {
            if ((N / i) % 2 == 1)
                pfac.push_back(i);
        }
    }

    for (int i = 0; i < pfac.size(); i++)
    {
        rv[i] = gogo (pfac[i]);
        //cout << pfac[i] << " " << rv[i] << "\n";
    }

    for (int i = 0; i < pfac.size(); i++)
    {
        for (int j = i + 1; j < pfac.size(); j++)
            if (pfac[j] % pfac[i] == 0)
            {
                rv[j] -= rv[i];
            }
    }

    ll ans = 0;
    for (int i = 0; i < pfac.size(); i++)
    {
        //cout << pfac[i] << " " << rv[i] << "\n";
        ans = ans + (2 * pfac[i] * rv[i]);
        ans %= MOD;
    }
    ans = (ans + MOD) % MOD;
    cout << ans << "\n";
}

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

const int MAX = 1e5 + 5;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

int main() {
    int n, k;
	scanf("%d %d", &n, &k);
	vector<int> s(n + 1, 0);
	map<int, int> mp;
	++mp[0];
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		int a;
		scanf("%d", &a);
		s[i] = (s[i - 1] + a) % k;
		if (i - k >= 0) {
			--mp[(s[i - k] - i % k + k) % k];
		}
		ans += mp[(s[i] - i % k + k) % k];
		++mp[(s[i] - i % k + k) % k];
	}
	printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  int n;
  cin >> n;
  Sieve s(n);
  ll ans = 1;
  vector<int> cnt(n + 1);
  for (int i = 1; i <= n; ++i) {
    auto primes = s.factor(i);
    for (auto p : primes) {
      cnt[p.first] += p.second; 
    }
  }
  rep(i, n + 1) {
    ans *= cnt[i] + 1;
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int max = Math.max(a, b);
		max = Math.max(max, c);
		int ans = a + b + c - max;
		for (int i = 1; i <= k; i++) {
			max *= 2;
		}
		System.out.println(ans + max);
		sc.close();
	}
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  string s;
  cin >> s;
  reverse(all(s));
  int n = sz(s);
  vi t(sz(s));
  t[0] = s[0] == 'T';
  REP(i,n){
    t[i] = t[i-1] + (s[i] == 'T');
  }
  int cnt = 0;
  rep(i,n){
    if(s[i] == 'S'){
      if(t[i] > cnt){
        cnt++;
      }
    }
  }
  int ans = n - cnt*2;
  cout << ans << endl;
}

Measured memory_bytes: 1300
#include <iostream>
#define For(i,x,y) for(register int i=(x); i<=(y); i++)
using namespace std;
const int maxn=1e5+10;
int h[maxn];
int ma[maxn];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    For(i,1,n)cin>>h[i];
    For(i,1,m)
    {
        int a,b;
        cin>>a>>b;
        ma[a]=max(ma[a],h[b]);
        ma[b]=max(ma[b],h[a]);
    }
    int ans=0;
    For(i,1,n)ans+=h[i]>ma[i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4324
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int second = Integer.parseInt(br.readLine());
		int hour = second/3600;
		second = second - hour * 3600;
		int minute = second/60;
		second = second - minute*60;
		System.out.println(hour+":"+minute+":"+second);
	}

}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

using namespace std;

using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const R INF = 1E40L;
const R PI = acos(-1.0L);
using P=complex<R>;
const P O=0.0L;
using L=struct{P s,t;};
using VP=vector<P>;

istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}
ostream& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

inline R det(P o,P a,P b){return imag(conj(a-o)*(b-o));}
inline int sdet(P o,P a,P b){return sgn(det(o,a,b));}

P cross(L a,L b){
	R u=det(a.s,b.s,b.t)/det(O,a.t-a.s,b.t-b.s);
	return (1-u)*a.s+u*a.t;
}

R area(const VP& pol){
	int n=pol.size();
	R sum=0.0;
	rep(i,n) sum+=det(O,pol[i],pol[(i+1)%n]);
	return abs(sum/2.0L);
}

VP convex_cut(const VP& pol,const L& l) {
	VP res;
	int n=pol.size();
	rep(i,n){
		P a = pol[i],b=pol[(i+1)%n];
		int da=sdet(l.s,l.t,a),db=sdet(l.s,l.t,b);
		if(da>=0) res.emplace_back(a);
		if(da*db<0) res.emplace_back(cross({a,b},l));
	}
	return res;
}

int main(void){
	int n,q;
	cin >> n;
	VP pol;
	rep(i,n){
		P p;
		cin >> p;
		pol.push_back(p); 
	}
	cin >> q;
	cout.precision(20);
	rep(i,q){
		P a,b;
		cin >> a >> b;
		L l={a,b};
		cout << fixed <<  area(convex_cut(pol,l)) << endl;
	}
	return 0;
}

Measured memory_bytes: 3220
//#define DEB1 //input from input.txt
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

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




/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    int N; cin >> N;
    string S; cin >> S;
    LL r =0;
    LL g = 0;
    LL b = 0;
    REP(i,N){
        if(S[i]=='R'){
            ++r;
        }else if(S[i]=='G'){
            ++g;
        }else{
            ++b;
        }
    }
    LL sum=0;
    sum = r*g*b;
    
    // minus rule2
    REP(x,N){
        CREP(y,1,(N-x-1)/2 ){
            if( S[x]!=S[x+y] && S[x]!=S[x+2*y] && S[x+y] != S[x+2*y] ){
                --sum;
            }
        }
    }

    cout << sum << endl;
    return;
}



// ----------------------------------------------
int main(){

#ifdef DEB1
    cout << "DEBUG MODE"  << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf()); //for debug
#endif

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		long e = lcm(c, d);

		long all = b - a + 1;
		long first = b / c - (a % c == 0 ? a / c : a / c + 1) + 1;
		long second = b / d - (a % d == 0 ? a / d : a / d + 1) + 1;
		long third = b / e - (a % e == 0 ? a / e : a / e + 1) + 1;

		System.out.println(all - first - second + third);

		sc.close();

	}

	private static long lcm(long m, long n) {
	    return m * n / gcd(m, n);
	}

	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}

}


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

#define F 4

const int mod[F]={1000000009,1000000021,1000000033,1000000087};

typedef struct hashNode{
  int hash[F];
} node;

node add(node a,node b){
  node x;
  for(int i=0;i<F;i++){
    x.hash[i]=(a.hash[i]+b.hash[i])%mod[i];
  }
  return x;
}

node minus(node a,node b){
  node c;
  for(int i=0;i<F;i++){
    c.hash[i]=(a.hash[i]-b.hash[i]+mod[i])%mod[i];
  }
  return c;
}

int isZero(node a){
  for(int i=0;i<F;i++) if(a.hash[i]>0) return 0;
  return 1;
}

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int *a=(int *)calloc(n,sizeof(int));
  int i,j;
  for(i=0;i<n;i++) scanf("%d",a+i);
  node *dp=(node *)calloc(k,sizeof(node));
  for(i=0;i<F;i++) dp[0].hash[i]=1;
  for(i=0;i<n;i++){
    for(j=k-1;j-a[i]>=0;j--){
      dp[j]=add(dp[j],dp[j-a[i]]);
    }
  }
  node *dp2=(node *)calloc(k+1,sizeof(node));
  int ans=0;
  for(i=0;i<n;i++){
    if(a[i]>=k) continue;
    for(j=0;j<a[i];j++) dp2[j]=dp[j];
    for(j=a[i];j<k;j++){
      dp2[j]=minus(dp[j],dp2[j-a[i]]);
    }
    for(j=k-1;j>=k-a[i];j--) if(!isZero(dp2[j])) break;
    if(j<k-a[i]) ans++;
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 384
def conv( input )
	input_a = input.split(//)

	oldc = input_a[ 0 ]
	n = 1
	output = ''

	1.upto( input_a.size - 1 ){ |i|
		if oldc == input_a[ i ]
			n += 1
		else 
			output += (n.to_s + oldc.to_s)
			oldc = input_a[ i ]
			n = 1
		end
	}
	if n > 0
		output += (n.to_s + oldc.to_s)
	end
	return output
end

ans = []
while (n  = $stdin.gets.chomp.to_i) != 0
	str = $stdin.gets.chomp
	n.times{
		newstr = conv( str )			
		str = newstr
	}	
	ans << str
end
ans.each{ |a| puts a }


Measured memory_bytes: 68784
#include<bits/stdc++.h>
#define test(t) for(cin>>t;t;--t)
#define rep(i,n) for(ll i=0;i<n;i++)
#define repr(i,k,n) for(ll i=k;i<n;i++)
#define repr_r(i,n) for(ll i=n-1;i>=0;i--)
#define pb push_back
#define f first
#define sec second
#define in cin>>
#define out cout<<
#define optimize ios_base::sync_with_stdio(0);cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll>pll;

bool ispalindrome(string s) {
    int i = 0, j = s.size()-1;
    while(i<j) {
        if(s[i++] != s[j--]) return false;
    }
    return true;
}

int main(){
	optimize
    string s; cin >> s;
    int n = s.size();
    string temp = "";
    bool flag = ispalindrome(s) && ispalindrome(s.substr(0, (n-1)/2)) && ispalindrome(s.substr((n+1)/2, n));
	if(flag) cout << "Yes";
    else cout << "No";
    return 0;
}

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


def solve(N: int, A: "List[int]"):
    print(max(A)-min(A))


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

if __name__ == '__main__':
    main()


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

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int mi=n+1,s=0;
	for(int i=0;i<n;i++)
	{
		int k;
		scanf("%d",&k);
		if(k<mi)mi=k,s=0;
		if(k==mi)s++;
	}
	printf("%d\n",(n-s+m-2)/(m-1));
	return 0;
}

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

using namespace std;

int main()
{
	string str;
	cin>>str;
	char a[200200];
	a[0]='Q';
	int length=0;
	for(int i=0;i<str.length();i++)
	{
	    if(str[i]=='T'&&a[length]=='S')
	    {
	    	length--;
		}
		else
		{
			length++;
			a[length]=str[i];
		}
	}
	cout<<length;
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  if(n<105) cout<<0<<endl;
  else if(n<135) cout<<1<<endl;
  else if(n<165) cout<<2<<endl;
  else if(n<189) cout<<3<<endl;
  else if(n<195) cout<<4<<endl;
  else cout<<5<<endl;
}



Measured memory_bytes: 256
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <sstream>
#include <cstring>
#include <numeric>
#include <ctime>
#include <cassert>
#include <unordered_set>
#include<unordered_map>
#include <random>
#include <valarray>
//#include <fstream>
#define MOD 1000000007
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define y0 y32479
#define y1 y95874
#define next next239
#define prev prev239
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

void Solve()
{
    ll n;
    cin>>n;
    vector<ll> v(n,0);
    rep(i,n)
        cin>>v[i];
    ll count=0;
    bool flag=false;
    rep(i,n)
    {
        while(v[i]%2==0)
        {
            v[i]/=2;
            flag=true;
            count++;
        }
    }
    
        cout<<count<<"\n";
}

int main()
{
    fastIO();
    int t;
    t=1;
    while (t--)
    {
        Solve();
    }
    return 0;
}

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

using namespace std;

int main(){
    int n;
    string s;
    int cnt = 0;

    cin >> n >> s;

    for(int i = 0; i < n; i++){
        if(s[i] == 'R') cnt++;
    }

    bool ans = (n - cnt < cnt);
    puts(ans ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())
Score = [0]*(N+1)
for i in range(Q):
    A = int(input())
    Score[A] += 1
for i in range(1, N+1):
    if Score[i] + K - Q > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4680
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long k = sc.nextLong();
		if(a > k)
			a -= k;
		else {
			k -= a;
			a = 0;
			if(b > k)
				b -= k;
			else
				b = 0;
		}
		System.out.println(a + " " + b);
	}

}


Measured memory_bytes: 23764
n,m=map(int,input().split())
coins=list(map(int,input().split()))
dp=[float('inf')]*(n+1)
dp[0]=0
for i in range(m):
    for j in range(1,n+1):
        if j>=coins[i]:
            dp[j]=min(dp[j],dp[j-coins[i]]+1)
print(dp[n])


Measured memory_bytes: 7524
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
        return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
        return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}
 
template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
    for (const T &x : s)
        out << x << ' ';
    return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define epsilon 0.00000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl "\n"
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    fast();
    ll n,m;
    cin>>n>>m;
    vv e(n,vi());
    for(ll i=0;i<m;i++)
    {
        ll u,v;
        cin>>u>>v;
        u--;v--;
        e[u].pb(v);
        e[v].pb(u);
    }
    
    ll num=0;
    vb vis(n,false);
    for(ll i=0;i<n;i++)
    {
        if(!vis[i])
        {
            num++;
            vis[i]=true;
            queue <ll> q;
            q.push(i);
            while(!q.empty())
            {
                ll u=q.front();
                q.pop();
                
                for(ll v:e[u])
                {
                    if(!vis[v])
                    {
                        vis[v]=true;
                        q.push(v);
                    }
                }
            }
        }
    }
    cout<<num-1<<nl;
}


Measured memory_bytes: 9252
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>

using namespace std;

int main()
{
    long long x,s=100,i=0;
    scanf("%lld",&x);
    while(s<x)
    {
        s=s+s/100;
        i++;
    }
    printf("%lld\n",i);
    //system("pause");
    return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = (int) 1e5 + 100;
char s[N];


int main(int,  char **)
{
#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	scanf("%s", s);

	int sum = 0, fo = 0;

	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'c')
		{
			printf("No\n");
			continue;
		}
		if (s[i] == 'a')
		{
			if (sum < a + b)
			{
				sum++;
				printf("Yes\n");
			}
			else
			{
				printf("No\n");
			}
			continue;
		}
		if (s[i] == 'b')
		{
			if (sum < a + b && fo < b)
			{
				sum++;
				fo++;
				printf("Yes\n");
			}
			else
			{
				printf("No\n");
			}
			continue;
		}
		throw;
	}

	return 0;
}



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


int main(){
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> C(N);
	vector<vector<int>> A(N,vector<int>(M));
	rep(i,N){
		cin >> C[i];
		rep(j, M){
			cin >> A[i][j];
		}
	}
	int ans = 1001001001;
	rep(bit,(1<<N)){
		int tmp = 0;
		vector<int> rikai(M);
		bool ok = true;
		rep(i,N){
			if(bit & (1<<i)){
				tmp += C[i];
				rep(j,M){
					rikai[j] += A[i][j];
				}
			}
		}
		rep(i,M){
			if(rikai[i]<X) ok = false;
		}
		if(ok) ans = min(ans,tmp);
	}
	if(ans == 1001001001) cout << -1 << endl;
else 

		  cout << ans << endl;




}














Measured memory_bytes: 3628
li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(li[k - 1])


Measured memory_bytes: 2940
N, L = [int(i) for i in input().split()]

min_ = L
max_ = L + N -1

def eat_apple(N, L):
    if max_<0:
        return max_ 
    if L < 0:
        return 0
    return L

print((min_+max_)*(max_-min_+1)//2 - eat_apple(N, L))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[1000000];
int main(){
dp[0]=0;
int n;
cin>>n;
vector<ll>a(n);
for(int i=0;i<n;i++)cin>>a[i];
dp[1]=abs(a[1]-a[0]);
for(int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i-2]-a[i]));
}
cout<<dp[n-1]<<'\n';
return 0;    
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func main() {
	var x, y, z int
	_, _ = fmt.Scanf("%d %d %d", &x, &y, &z)

	fmt.Println(answer161A(x, y, z))
}

func answer161A(x int, y int, z int) string {
	return fmt.Sprintf("%d %d %d", z, x, y)
}


Measured memory_bytes: 1828
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = input()

odd = ('R', 'U', 'D')
even = ('L', 'U', 'D')

for i, s in enumerate(S):
    if not i % 2 and s not in odd:
        print('No')
        sys.exit()
    if i % 2 and s not in even:
        print('No')
        sys.exit()

print('Yes')



Measured memory_bytes: 9028
import java.util.*;
public class Main
{
  	public static void main(String args[])
    {
		Scanner sc=new Scanner(System.in);
		String s="";
      	if(sc.hasNext())
          s=sc.next();
		char []ch=s.toCharArray();
		int c=0;
		for(int i=0; i<ch.length-1;i++)
		{
		if(ch[i] != ch[i+1])
			c++;
		}
		System.out.println(c);
    }
}

Measured memory_bytes: 25684
loop do
    n, m, a = gets.chomp.split.map(&:to_i)

    break if n == 0 && m == 0 && a == 0

    hl = []

    m.times do
        h, p, q = gets.split.map(&:to_i)
        hl.push([h, p, q])
    end

    hl = hl.sort_by(&:first).reverse

    ans = a

    for i in 0..m-1
        if ans == hl[i][1]
            ans = hl[i][2]
        elsif ans == hl[i][2]
            ans = hl[i][1]
        end
    end
    puts ans

end


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

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

    int n;
    cin >> n;
    vi v(n);
    rep(i, n) { cin >> v[i]; }

    sort(all(v));

    double ans = v[0];
    rep(i, n - 1) { ans = (ans + v[i + 1]) / 2; }

    cout << ans << endl;

    return 0;
}


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

int main(){
	int n;
	cin >> n;
	LL a[n];
	LL num = 0;
	LL minprice = 1;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		LL d = (a[i]-1LL)/minprice;
		num += d;
		if(d != 0) a[i] = 1;
		if(a[i] == minprice){
			minprice++;
		}
	}
	cout << num << endl;
}


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

using namespace std;

const void chmax(double &a, double b)
{
  a = max(a, b);
}


struct edge
{
  int to, cost, v;
};

int main()
{
  int N, M, P;
  vector< edge > g[200];

  cin >> N >> M >> P;
  for(int i = 0; i < M; i++) {
    int s, t, d, v;
    cin >> s >> t >> d >> v;
    --s, --t;
    g[s].emplace_back((edge) {t, d, v});
    g[t].emplace_back((edge) {s, d, v});
  }

  double dp[1001][200];
  fill_n(*dp, 1001 * 200, -1);
  dp[0][0] = 0;
  for(int i = 0; i < P; i++) {
    for(int j = 0; j < N; j++) {
      if(dp[i][j] < 0) continue;
      for(auto &e : g[j]) {
        chmax(dp[i + 1][j], dp[i][j] + (double) e.v / e.cost);
        if(i + e.cost <= P)
          chmax(dp[i + e.cost][e.to], dp[i][j] + e.v);
      }
    }
  }

  cout << fixed << setprecision(10) << dp[P][0] << endl;
}

Measured memory_bytes: 5320
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0){
        cout<<(b-a)/2<<endl;
    }
    else{
        cout<<min(a-1,n-b)+1+(b-a-1)/2<<endl;
    }
}


Measured memory_bytes: 256
N, K =map(int, input().split())
a = int(input())
M = a
m = a
ans = [[a]]
for _ in range(N - 1):
    a = int(input())
    if a > M+K or a < m-K:
        ans[0].append(a)
        M = max(M, a)
        m = min(m, a)
        continue
    M = max(M, a)
    m = min(m, a)
    j = 1
    check = 1
    while check:
        if j == len(ans)+1:
            ans[0].append(a)
            break
        for p in ans[-j]:
            if abs(p-a) <= K:
                if j == 1:
                    ans.append([a])
                else:
                    ans[-j+1].append(a)
                check = 0
                break
        j += 1
print(len(ans))  

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

const int N = 1e5+9, M = 1e7, OO = 0x7f7f7f7f;

int main(){
    int n;
    scanf("%d",&n);
    char s[1000];
    scanf("%s",s);
    if(n&1)puts("No");
    else {
        int temp =1;
        int j = n/2;
        for(int i=0 ; i<n/2 ; ++i,++j)if(s[i]!=s[j])temp=0;
        temp ? puts("Yes"): puts("No");
    }
    return 0;
}


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

int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	int ans = 0, mx = 0;
	for(int i=0; i<n; i++) {
		int t;
		cin >> t;
		ans += max(0ll, mx - t);
		mx = max(mx, t);
	}
	cout << ans;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    while (cin >> a >> b) {
        int x, y;
        bool flag = true;
        if ((b - a - a) % 2 == 0)
            x = (b - a - a) / 2;
        else flag = false;
        if ((4 * a - b) % 2 == 0)
            y = (4 * a - b) / 2;
        else flag = false;
        if (flag && x >= 0 && y >= 0)
            cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3624
n = int(input())
xy = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x_,y_ = map(int,input().split())
        xy[i].append((x_-1,y_))
ans = 0
for i in range(1,2**n):
    flag = 0
    for j in range(n):
        if i>>j&1:
            for x,y in xy[j]:
                if i>>x&1 != y:
                    flag = 1 
                    break
    if flag==0:
        ans = max(ans, bin(i)[2:].count("1"))
print(ans)

Measured memory_bytes: 9204
N, M = gets.split.map(&:to_i)
cards = gets.split.map(&:to_i).sort
actions = Array.new(M) { gets.split.map(&:to_i) }.sort_by{|a| -a[1] }

result = 0

cards.each do |tmp|
  j = actions.first&.dig(1)
  if j && j > tmp
    result += j
    if actions.first[0] - 1 == 0
      actions.shift
    else
      actions[0] = [actions.first[0] - 1, actions.first[1]]
    end
  else
    result += tmp
  end
end

puts result


Measured memory_bytes: 20760
#include <stdio.h>

int main()
{
    int N,i;
    long long L[3];

    L[0]=2;
    L[1]=1;

    scanf("%d",&N);
    if(N>=2){
        for(i=1;i<N;i++){
            L[2] = L[0] + L[1];
            L[0] = L[1];
            L[1] = L[2];
        }
    }else{
        printf("%lld",L[N]);
        return 0;
    }

    printf("%lld",L[2]);

    return 0;

}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		long N = Integer.parseInt(tmp[0]);
		long M = Integer.parseInt(tmp[1]);
		if (N == 1 && M == 1)
			System.out.println(1);
		else if (N == 1 || M == 1)
			System.out.println(N * M - 2);

		else
			System.out.println(N * M - 2 * (N + M - 2));
	}
}


Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>
#include <map>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

//////////////////////////////////////////////////////////////



int main() {

	long long X;
	cin >> X;

	long long e = 100;
	long long Y = 0;
	while (e < X) {
		e = e * 1.01;
		Y++;
	}
	
	cout << Y << endl;

}


Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int n;
  cin >> n;
  for (int i = n; ; i += n) {
    if (i % 2 == 0) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
m=998244353
M=1<<20
f=[1]*M
g=[1]*M
h=[1]*M
h[0]=0
for i in range(2,M):
	f[i]=f[i-1]*i%m
	h[i]=m-h[m%i]*(m//i)%m
	g[i]=g[i-1]*h[i]%m
A,B=map(int,input().split())
if A<B:A,B=B,A
a=0
b=1
for j in range(1,B+1):
	a+=b*f[A+B-j]*g[B-j]*g[A]
	b=b*2%m
print((a*f[A]*f[B]*g[A+B]+A)%m)

Measured memory_bytes: 65004
// 問題URL
//

import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer r = Integer.parseInt(scanner.next());

        System.out.println(r*r*3);
    }
}

Measured memory_bytes: 21716
x=int(input())
xr=100010


s=[True for _ in range(xr)]

for i in range(2, xr):
    if s[i]:
        se=i*2
        while se < xr:
            s[se]=False
            se+=i


while True:
    if s[x] == True:
        print(x)
        exit()
    else:
        x+=1


Measured memory_bytes: 44912
#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.at(i);
	}
	int alice,bob;
	int temp = 0;
	int swap;
	int i = 0,j = 0;
	while (a.size() > j+1) {
		while (a.size() > i+1) {
			swap = 0;
			if (a.at(i) < a.at(i+1)) {
				temp = a.at(i);
				a.at(i) = a.at(i+1);
				a.at(i+1) = temp;
				swap = 1;
			}
			i++;
			if (swap > 0) {
				i = 0;
			} 
		}
		j++;
		i = j;
	}
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			alice += a.at(i);
		} else {
			bob += a.at(i);
		}
	}
	cout << alice - bob << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int x = stdIn.nextInt();
    int y = stdIn.nextInt();

    if (x < y) {
      int t = x;
      x = y;
      y = t;
    }
    x = x % y;

    while (x != 0) {
      int t = x;
      x = y;
      y = t;
      x = x % y;
    }

    System.out.println(y);
  }
}

Measured memory_bytes: 26148
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

int main() {
    ll N,K;
    cin >> N >> K;
    ll p[N];
    rep(i,N) cin >> p[i];
    sort(p,p+N);
    ll out = 0;
    rep(i,K) out += p[i];
    cout << out << endl;
    return 0;
}



Measured memory_bytes: 3640
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

def lcm(a, b): return a * b // math.gcd(a, b)

sys.setrecursionlimit(1000000)

class Eratosthenes:
    # https://cp-algorithms.com/algebra/prime-sieve-linear.html
    def __init__(self, n):
        primes, lp = [], [0] * (n + 1)
        for i in range(2, n + 1):
            if lp[i] == 0:
                primes.append(i)
                lp[i] = i

            for pj in primes:
                if pj > lp[i] or i * pj > n: break
                lp[i * pj] = pj
        self.primes, self.lp = primes, lp

    def is_prime(self, x): return self.lp[x] == x

    def factors(self, x):
        ret = []
        while x > 1:
            ret.append(self.lp[x])
            x //= self.lp[x]
        return ret


def main():
    N = I()
    A = LI()

    era = Eratosthenes(1 + 10 ** 6)
    cumgcd = reduce(lambda x,y: math.gcd(x, y), A)
    s = set()
    for ai in A:
        for i in set(era.factors(ai)):
            if i in s:
                break
            s.add(i)
        else:
            continue
        break
    else:
        print("pairwise coprime")
        return

    if cumgcd == 1:
        print("setwise coprime")
    else:
        print("not coprime")


if __name__ == '__main__':
    main()

Measured memory_bytes: 188332
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;


int main() {
  ll N, A;
  cin >> N;
  map<ll, ll> counter;
  vector<ll> vec1, vec2;
  vec1.reserve(N);
  vec2.reserve(N);
  for (auto i = 0;i < N;i ++) {
    cin >> A;
    vec1.push_back(A);
    vec2.push_back(A);
  }
  sort(vec2.begin(), vec2.end());
  A = vec2[0];
  ll c = 1;
  ll sum = 0;
  for (auto i = 1; i < N; i ++) {
    if (A != vec2[i]) {
      if (c == 1) {
        counter.insert({A, 0});
      } else if (c == 2) {
        counter.insert({A, 1});
        sum += 1;
      } else {
        ll d = (c*(c-1))/2;
        ll e = ((c-1)*(c-2))/2;
        sum += d;
        counter.insert({A,d-e});
      }
      c = 1;
      A = vec2[i];
    } else {
      c ++;
    }
  }
  if (c == 1) {
    counter.insert({A, 0});
  } else if (c == 2) {
    counter.insert({A, 1});
    sum += 1;
  } else {
        ll d = (c*(c-1))/2;
        ll e = ((c-1)*(c-2))/2;
        sum += d;
        counter.insert({A,d-e});
  }

  for (auto i = 0; i < N; i ++) {
    cout << sum - counter[vec1[i]] << endl;
  }

  return 0;
}

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

#define int long long
using namespace std;

int N;
int number[100004];
int minusCnt = 0;
int sum = 0;

signed main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> number[i];
		if (number[i] < 0)
		{
			number[i] = -number[i];
			minusCnt += 1;
		}
		sum += number[i];
	}

	if (minusCnt % 2 == 1)
	{
		sort(number, number + N);
		sum -= number[0] * 2;
	}

	cout << sum;
}

Measured memory_bytes: 1024