akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    int N,X; cin >> N >> X;
    vi x(N); rep(i,N) cin >> x[i];

    sort(x.begin(), x.end());
    int shift = min(x[0], X);
    X -= shift;
    rep(i,N) x[i] -= shift;
    int ans;
    if(x[N-1] != 0) {
        ans = x[N-1];
        if(X != 0) ans = gcd(ans, X);
        rep(i,N-1){
            if(x[i] != 0)
                ans = gcd(ans, x[i]);
        }
    }else{
        ans = X;
    }

    cout << ans;
    return 0;
}


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

int
main(void) {

    std::vector<int> v;
    for (int i = 0; i < 10; ++i) {
        int num;
        std::cin >> num;
        v.push_back(num);
    }   
    std::sort(v.begin(), v.end(), std::greater<int>() );

    for (int i = 0; i < 3; ++i) {                                                                                                                                                                   
        std::cout << v[i] << std::endl;
    }   

    return 0;
}

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

bool have(int x , vector<int> &v) {
  bool ans = false;
  for (int i = 0 ; i < v.size() ; i ++) {
    if (v[i] == x) {
      ans = true;
      break;
    }
  }
  return ans;
}

int main(){
  int x , n , p ;
  cin >> x >> n;
  vector<int>  v(200);
  for (int i = 0 ; i < 200 ; i ++) {
    v[i] = i;
  }
  for (int i = 0 ; i < n ; i ++) {
    cin >> p;
    v.erase(remove(v.begin(), v.end(), p), v.end());
  }

  for (int i = 0 ; i < 300 ; i ++) {
    if (have(x - i , v)) {
      cout << x - i << endl;
      break;
    } else if (have(x + i , v)) {
      cout << x + i << endl;
      break;
    }
  }
}

Measured memory_bytes: 3636
N = int(input())
A = []
B = []
for i in range(N):
    Ai,Bi = map(int,input().split())
    A.append(Ai)
    B.append(Bi)
ans = 0
for i in reversed(range(N)):
    if (A[i]+ans) % B[i] == 0:
        continue
    ans += B[i]-((A[i]+ans) % B[i])
print(ans)


Measured memory_bytes: 11052
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let N = parseInt(input[0][0], 10);

    let ans = 0;
    if (N >= 3*5*7) ans++;
    if (N >= 3*5*11) ans++;
    if (N >= 3*5*13) ans ++;
    if (N >= 27*5) ans ++;
    if (N >= 27*7) ans ++;

    console.log(ans);
}





Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29628
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	vector<vector<int>>A(3, vector<int>(3));
	rep(i, 3)rep(j, 3)cin >> A[i][j];
	int N;
	cin >> N;
	vector<int>b(N);
	rep(i, N)cin >> b[i];
	vector <vector<bool>>v(3, vector<bool>(3));
	rep(i, 3)rep(j, 3)v[i][j] = false;
	rep(i, N)rep(j, 3)rep(k, 3)if (b[i] == A[j][k])v[j][k] = true;
	rep(i, 3) {
		bool tate = true;
		bool yoko = true;
		rep(j, 3) {
			if (v[i][j] == false)tate = false;
			if (v[j][i] == false)yoko = false;
		}
		if (tate || yoko) {
			cout << "Yes";
			return 0;
		}
	}
	if (v[0][0] && v[1][1] && v[2][2]) {
		cout << "Yes";
		return 0;
	}
	if (v[0][2] && v[1][1] && v[2][0]) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
}

Measured memory_bytes: 256
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())

ans = 0
div1,div2 = [],[]
for m in range(1,int(M**.5)+1):
    if M%m == 0:
        div1.append(m)

for d in div1:
    if M%d == 0:
        div2.append(M//d)

div3 = div1+div2
div3.sort()
for d in div3:
    if d <= M//N:
        ans = d

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    string S;
    read(S);
    if(S == "ABC") write("ARC");
    else write("ABC");
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int r, d, x;
    cin >> r >> d >> x;
    for( int i = 0; i < 10; ++i ) {
        x = r * x - d;
        cout << x << endl;

    }
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n = int(input())
  As = numpy.array(list(map(int, input().strip().split())))
  xs = [0] * n
  
  xs[0] = sum([((-1)**i)*A for i, A in enumerate(As)])//2
  for i in range(1, n):
    xs[i] = As[i-1] - xs[i-1]
  print(' '.join(map(lambda x: str(int(2*x)), xs)))
  
if __name__=='__main__':
  main()



Measured memory_bytes: 24884
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int sumAmount = 0;
		float numAvarage = 0;
		int numCount = 0;
		while(stdIn.hasNext()){
			String[] temp = stdIn.next().split(",");
			sumAmount += Integer.valueOf(temp[0]) * Integer.valueOf(temp[1]);
			numAvarage += Integer.valueOf(temp[1]);
			numCount++;
		}
		numAvarage /= numCount;
		System.out.println(sumAmount +"\n" + Math.round(numAvarage));
	}
}

Measured memory_bytes: 11000
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int a,b,x;
      cin >> a >> b >> x;
      if(a<=x && x<=a+b) cout << "YES" << endl;
      else cout << "NO" << endl;
      return 0;}

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

using namespace std;

int main() {
  int A, B;
  
  cin >> A >> B;
  int product = A*B;
  
  if (product % 2 == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}
    

Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ubo upper_bound
#define lbo lower_bound
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pii >
#define all(x) x.begin(), x.end()
#define M vector<VI >

const int P = 1e9+7;
const int N = 10101010;

using namespace std;

bitset<N> rp;

int main(){

	int n;
	cin >> n;

	VL pr(n+1, 1);

	ll ans = 1;
	for(ll i=2; i<=n; i++){
		if(!rp[i]){
			for(int j=i; j<=n; j+=i){
				ll k = 1, r = i;
				while(!(j%r)){
					k++;
					r*=i;
				}
				rp[j] = 1;
				pr[j] *= k;
			}
		}

		ans += i*pr[i];
	}

	cout << ans << '\n';

	return 0;
}


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

int tannsaku (vector<int>a,vector<int>b,vector<int>c){
  
}

int main(){
  int a,b;
  cin >> a >> b;
  if(a*b%2 ==1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  }

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false



int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	int n;
	for (n = 1; (n + 1) * Y + (n + 2) * Z <= X; n++);
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 384
N, M = map(int, input().split())
students    = [ map(int, input().split()) for _ in range(N) ]
checkpoints = [ tuple(map(int, input().split())) for _ in range(M) ]

for a, b in students:
  min_dist = float('inf')

  for i in range(M):
    c, d = checkpoints[i]

    dist = abs(a - c) + abs(b - d)
    if dist < min_dist:
      min_dist = dist
      answer = i + 1
  print(answer) 

Measured memory_bytes: 3064
import java.util.*;

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

        if (n <= k) {
            System.out.println(0);
            return;
        }

        List<Integer> hpList = new ArrayList<>();
        for (int i = 0; i < n; i++) hpList.add(sc.nextInt());
        Collections.sort(hpList, Comparator.reverseOrder());
        
        long result = 0;
        for (int i = k; i < n; i++) result += hpList.get(i);

        System.out.println(result);
    }
}

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

int main(){
    int N;
    cin >> N;
    vector<double> V(N);
    for(int i=0; i<N; i++) cin >> V[i];
    sort(V.begin(), V.end());
    double ans = V[0];
    for(int i=1; i<N; i++) ans = (ans+V[i])/2;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


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

using namespace std;

int n,w,i,j,k,w0;
vector <int> v[4];

int main(){
	scanf("%d%d", &n, &w);
	
	int x,y;
	scanf("%d%d", &x, &y);
	
	w0 = x;
	
	v[0].push_back(y);
	
	for(i = 0; i < n - 1; i++){
		scanf("%d%d", &x, &y);
		v[x - w0].push_back(y);
	}
	
	for(i = 0; i < 4; i++){
		sort(v[i].begin(), v[i].end());
		reverse(v[i].begin(), v[i].end());
	}

	long long res = 0;
	
	long long sum0 = 0;
	
	for(i = 0; i <= v[0].size(); i++){
		long long sum1 = 0;
		for(j = 0; j <= v[1].size(); j++){
			long long sum2 = 0;
			int p = v[3].size() - 1;
			long long sum3 = 0;
			
			for(k = 0; k < v[3].size(); k++)
			sum3 += v[3][k];
			
			for(k = 0; k <= v[2].size(); k++){
				long long tot = (long long)i * w0 + (long long)j * (w0 + 1) + (long long)k * (w0 + 2);
				
				if(tot > w) break;
				
				long long remain = (w - tot) / (w0 + 3);
				
				while(p + 1 > remain){
					sum3 -= v[3][p];
					p--; 
				}
				
				res = max(res, sum0 + sum1 + sum2 + sum3);
				
				if(k != v[2].size())
				sum2 += v[2][k];
			}
			if(j != v[1].size())
			sum1 += v[1][j];
		}
		if(i != v[0].size())
		sum0 += v[0][i];
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define lb lower_bound
#define ld long double
using namespace std;
bool pal(string s){
	int n = s.size();
	int i = 0;
	int j = n-1;
	while(i<=j){
		if(s[i]!=s[j])
			return 0;
		i++,j--;
	}
	return 1;
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	int n = s.size();
	if(pal(s)){
		int len = n/2;
		string a = s.substr(0,len);
		string b = s.substr(len+1);
		if(pal(a) && pal(b))
			cout<<"Yes";
		else cout<<"No";
	}
	else cout<<"No";
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String ans = "YES";
        if ((a.charAt(0) != b.charAt(2)) || (a.charAt(1) != b.charAt(1)) || (a.charAt(2) != b.charAt(0))) {
            ans = "NO";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
A, B, C, K = map(int, input().split())

ans = 0
d = min(A, K)
#print('d:', d)
ans += d
K -= d
d = min(B, K)
#print('d:', d)
ans += 0
K -= d
d = min(C, K)
#print('d:', d)
ans -= d
K -= d

print(ans)


Measured memory_bytes: 9184
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] nums = new int[n];
        int min = 100;
        int max = 1;
        for (int i = 0; i < n; i ++){
            nums[i] = scan.nextInt();
            min = Math.min(min, nums[i]);
            max = Math.max(max, nums[i]);
        }
        int result = Integer.MAX_VALUE;
        for (int i = min; i <= max; i ++){
            int ans = 0;
            for (int j = 0; j < n; j ++){
                ans += Math.pow(nums[j] - i, 2);
            }
            result = Math.min(ans, result);
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 22604
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort(all(v))
#define INF 1000000007
#define fcout cout << fixed << setprecision(15)
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 mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );};



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

  int n, k;
  cin >> n >> k;
  ll h[100010];
  rep(i, n) cin >> h[i];
  ll dp[100100];
  fill(dp, dp + 100100, INF);
  dp[0] = 0;
  rep(i, n) {
    REP(j, 1, k + 1) {
      dp[i + j] = min(dp[i + j], (dp[i] + abs(h[i] - h[i + j])));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
int pwise(int b);
int a[10000006]={0};
int gcd(int a,int b);
int main(int argc, char *argv[])
{
	int n,i,j,gd,pair=1,set=0;
	scanf("%d",&n);
	int b[n];
	for(i=0;i<n;i++){
		scanf("%d",&b[i]);
		a[i]=0;
	} 
	
	gd=b[0];
	for(i=1;i<n;i++)
		gd=gcd(gd,b[i]);
	if(gd==1)set=1;
	for(i=0;i<n;i++){
		pair=pwise(b[i]);
		if(!pair)break;
	}
	if(pair)
		printf("pairwise coprime\n");
	else if(set)
		printf("setwise coprime\n");
	else
		printf("not coprime\n");
}
int gcd(int a,int b){
	int tmp;
	while(a!=0){
		tmp=a;
		a=b%a;
		b=tmp;
	}
	return b;
}
int pwise(int b){
	int i,pair=1,x,y;
	for(i=1;i*i<=b;i++){
		if(!(b%i)){
			y=b/i;x=i;
			if(a[x]||a[y]){
				pair=0;break;
			}
			if(x!=1)
				a[x]=1;
			if(y!=1)
				a[y]=1;
		}
		
	}
	return pair;
}
					

Measured memory_bytes: 9420
n = int(input())
h_list = list(map(int, input().split()))

cost_list = [0] * len(h_list)

cost_list[0] = 0
cost_list[1] = abs(h_list[1] - h_list[0])

for i in range(2, n):
    cost_list[i] = min(abs(h_list[i-1] - h_list[i]) + cost_list[i-1],
                       abs(h_list[i-2] - h_list[i]) + cost_list[i-2])

print(cost_list[-1])


Measured memory_bytes: 52452
#include <bits/stdc++.h>
using namespace std;
double f[301][301][301];
int main()
{
	int n,i,j,k;
	int a,n1=0,n2=0,n3=0;
	double s1,s2,s3;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a);
		if(a==1)
			n1++;
		else if(a==2)
			n2++;
		else if(a==3)
			n3++;
	}
	f[0][0][0]=0;
	for(k=0;k<=n;k++)
	{
		for(j=0;j+k<=n;j++)
		{
			for(i=0;i+j+k<=n;i++)
			{
				if(i==0&&j==0&&k==0)
					continue;
				s1=s2=s3=0;
				if(k>0)
					s3=f[i][j+1][k-1]*(double)k/(i+j+k);
				if(j>0)
					s2=f[i+1][j-1][k]*(double)j/(i+j+k);
				if(i>0)
					s1=f[i-1][j][k]*(double)i/(i+j+k);
				f[i][j][k]=s1+s2+s3+(double)n/(i+j+k);
				//printf("%d %d %d %f\n",i,j,k,f[i][j][k]);
			}
		}
	}
	printf("%.10lf",f[n1][n2][n3]);
	return 0;
}

Measured memory_bytes: 213248
/* Coached by rainboy */
#include <stdio.h>

long long solve(long long n) {
	if (n % 4 == 0)
		return n;
	else if (n % 4 == 1)
		return n - 1 ^ n;
	else if (n % 4 == 2)
		return n - 2 ^ n - 1 ^ n;
	else
		return 0;
}

int main() {
	long long a, b;

	scanf("%lld%lld", &a, &b);
	printf("%lld\n", solve(b) ^ solve(a - 1));
	return 0;
}


Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
 
public class Main implements Runnable {
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }
    
    public void run() {
        FastScanner sc = new FastScanner();
        
        int n = sc.nextInt();
        int k = sc.nextInt();

    	System.out.println(partition(n-k,k));

    }
    
	//分割数をdpで求める
	//nをk個の非負整数の和で表す（⇔k個以下の自然数の和で表す）場合の数
	static int partition(int n, int k){
		if(n<0){return 0;} //こうしておくことで、partition(n-k,k)でnを丁度k個の自然数で表す組合せの数を計算できる
		if(n==0){return 1;}
		int mod = 1000000007;
		if(k>n){k=n;} //無駄な計算を省ける。テーブルごと使う場合は注意。
		int[][] dp = new int[n+1][k+1];
		dp[0][0] = 1;
		for(int i=0;i<=n;i++){
			dp[i][1] = 1; 
		}
		for(int i=2;i<=k;i++){
			dp[0][i] = 1;
			dp[1][i] = 1; 
		}
		
		for(int i=1;i<=n;i++){
			for(int j=2;j<=k;j++){
				if(i-j>=0){
					dp[i][j] = dp[i][j-1] + dp[i-j][j]; //0を最低1つ含む + 丁度k個の自然数の和
					dp[i][j] %= mod;
				}
				else{
					dp[i][j] = dp[i][j-1];
				}
			}
		}
		
		return dp[n][k];
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextIntArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 25376
#include <bits/stdc++.h>
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
const int N = 500050;
using namespace std;
int gi(){
  char ch=getchar(); int x=0,q=0;
  while(ch<'0' || ch>'9') (ch=='-'?q=1:0),ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int x[N],t[N],y[N],o[N],tot,top;
long long ans=1e18;
struct d{
  int x,s;
  bool operator < (const d &c) const {
    return s<c.s;
  }
}p[N];
int main(){
  int n=gi(),m=0,g=0;
  for (int i=1; i<=n; ++i){
    x[i]=gi(),y[i]=gi();
    p[++tot]=(d){i,o[++top]=x[i]};
    p[++tot]=(d){i,o[++top]=y[i]};
  }
  sort(p+1,p+tot+1);
  sort(o+1,o+top+1);
  top=unique(o+1,o+top+1)-o-1;
  for (int i=1; i<=tot; ++i)
    p[i].s=lower_bound(o+1,o+top+1,p[i].s)-o;
  int a=1e9,b=-1e9,c=1e9,d=-1e9;
  for (int i=1; i<=n; ++i){
    if (x[i]<y[i]) swap(x[i],y[i]);
    a=Min(a,x[i]),b=Max(b,x[i]);
    c=Min(c,y[i]),d=Max(d,y[i]);
  }
  ans=Min(ans,1ll*(b-a)*(d-c));
  for (int i=1; i<=tot; ++i){
    while(m!=n&&g<tot){
      ++t[p[++g].x];
      if (t[p[g].x]==1)
	++m;
    }
    if (m==n)
      ans=Min(ans,1ll*(b-c)*(o[p[g].s]-o[p[i].s]));
    --t[p[i].x];
    if (!t[p[i].x]) --m;
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 10752
import sys
from collections import Counter

input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

counter = Counter(A)
# print(counter)
ans = 0
tmp = 0
for n, count in counter.items():
    r = (count - 1) // 2
    count -= 1 + 2*r
    ans += 2*r
    if count == 1:
        tmp += 1

print(N - ans - tmp - tmp % 2)

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

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NK[0]; var K = NK[1];
            var p = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var expected = p.Select(n => (decimal)n).Select(n => (n + 1) / 2).ToArray();

            Decimal sum = 0;
            for (int i = 0; i < K; i++) sum += expected[i];
            var result = sum;
            for (int i = 1; i + K - 1 < N; i++)
            {
                sum -= expected[i - 1];
                sum += expected[i + K - 1];
                if (sum > result) result = sum;
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 33628
import sys
sys.setrecursionlimit(10**6)

n, l = map(int, input().split())

li = [i for i in range(l,l+n)]

if 0 in li:
    ans = sum([i for i in range(l,l+n)])
elif li[0] > 0:
    ans = sum([i for i in range(l+1,l+n)])
else:
    ans = sum([i for i in range(l,l+n-1)])
print(ans)

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

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;

const ll INF = 1e18;
const int MAXN = 1e6 + 5;
const int MOD = 20200429;

ll N, ans = 2;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> N;

	if(N == 2) {
		cout << 1;
		return 0;
	}

	for(ll i=2; i*i<=N; i++) if(N % i == 0) {
		ll x = N;
		while(x % i == 0) x /= i;
		if(x % i == 1) ans++;

		if(i*i != N) {
			x = N;
			while(x % (N/i) == 0) x /= (N/i);
			if(x % (N/i) == 1) ans++;
		}
	}
	N--;
	for(ll i=2; i*i<=N; i++) if(N % i == 0) {
		ans++;
		if(i*i != N) ans++;
	}

	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){ return modpow(x, MOD-2); }
ll in(){ ll x; scanf("%lld",&x); return x; }
string in_s(){ string res;cin >> res;return res; }
bool was_output = false;
template<class t>
void output(t a){ if(was_output)cout << " "; cout << a; was_output = true; }
void outendl(){ was_output = false; cout << endl; }

int n;
vvector<ll> line;

void input(){
    n = in();
    line.resize(n,vector<ll>(2));
    foreach(i,line){
        i[0] = in();
        i[1] = in();
    }
}

ll cul_dis(multiset<ll> &s){
    return *s.rbegin() - *s.begin();
}

ll solve(){
	ll res = INFLL;
	multiset<ll> mins;
	multiset<ll> maxs;
    foreach(i,line){
        if(i[0]>i[1])swap(i[0],i[1]);
        mins.insert(i[0]);
        maxs.insert(i[1]);
    }
    sort(all(line));
    res = cul_dis(maxs) * cul_dis(mins);
    foreach(i,line){
        mins.erase(mins.find(i[0]));
        maxs.insert(i[0]);
        mins.insert(i[1]);
        maxs.erase(maxs.find(i[1]));
        chmin(res,cul_dis(maxs)*cul_dis(mins));
    }
    return res;
}

int main(){
    input();
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 29952
uses crt;
var i,n,a,b:longint;
    t,t1:string;
begin
        clrscr;
        readln(n);
        readln(t);
        a:=length(t)div 2;
        b:=n div 2;
        if length(t)<1 then write('NO')else
        begin
        for i:=1 to a do
        t1:=t1+t[i];
        delete(t,1,b);
        if t=t1 then write('Yes') else write('No');
        end;
        readln
end.


Measured memory_bytes: 256
H,W,K=map(int, raw_input().split())

dp=[  [ 0 for w  in range(W+1) ]  for h in range(H+1)   ] 


dp[0][1]=1


h=0
for h in range(H):
	for t in range(2**(W-1)):
		s=str(bin(t))[2:]
		if len(s)<W: s=(W-len(s)-1)*"0"+s

		v=0
		for i,x in enumerate(s):
			x=int(x)
			if x==0:
				v=0
			elif x==1:
				v+=1
				if v==2:
					break
		else:
		#	print "t,bin(t)::: ",t,bin(t),"OK",s
			V=[0 for w  in range(W+1)]	#Visit
			for k,x in enumerate(s):
				k+=1
				if x=="1":
				#	print "dp[",h+1,"][",k,"] += dp[",h,"][",k+1,"]",1
					dp[h+1][k]+=dp[h][k+1]
					V[k]=1
				#	print "dp[",h+1,"][",k+1,"] += dp[",h,"][",k,"]",1
					dp[h+1][k+1]+=dp[h][k]
					V[k+1]=1
			for k in range(1,W+1):
				if V[k]==0:
				#	print "dp[",h+1,"][",k,"] += dp[",h,"][",k,"]",2
					dp[h+1][k]+=dp[h][k]
								
										

	#	print "h,s,dp,V::: ",h,s, dp,V
				

print dp[-1][K]%(10**9+7)

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

using namespace std;
typedef long long ll;
ll n,q,x,t;
int main()
{
    cin>>q>>n; vector<ll> a[q];
    for(ll i=0;i!=n;++i)
    {
        ll c; cin>>c>>t;
        if(c>0)
        {
            if(c==1)
            {
                if(a[t].size()>0)
                {
                    for(ll j=0;j<a[t].size()-1;++j) cout<<a[t][j]<<' ';
                    cout<<a[t][a[t].size()-1];
                }
                cout<<'\n';
            }
            else a[t].clear();
        }
        else
        {
            cin>>x;
            a[t].push_back(x);
        }
    }
    return 0;
}



Measured memory_bytes: 8744
N,K,Q = map(int,input().split())

S = []
for _ in range(Q):
    S.append(input())


A = [0]*N

for i in range(len(S)):
    A[int(S[i])-1] += 1

for i in range(N):
    if K-Q+A[i] >0:
        print('Yes')
    else:
        print('No')



Measured memory_bytes: 11016
import sys
 
chash = {}
for i in range( ord( 'a' ), ord( 'z' )+1 ):
    chash[ chr( i ) ] = 0
 
while True:
    line = sys.stdin.readline().rstrip()
    if not line:
        break
    for i in range( len( line ) ):
        if line[i].isalpha():
            chash[ line[i].lower() ] += 1
 
for i in range( ord( 'a' ), ord( 'z' )+1 ):
    print( "{:s} : {:d}".format( chr( i ), chash[ chr( i ) ] ) )

Measured memory_bytes: 4236
#include <bits/stdc++.h>
using namespace std;
int gcd(int &a, int &b){
  if (a%b == 0){
    return(b);
  }
  else{
    return(gcd(b, a%b));
  }
}

int gcd3(int &a ,int &b, int &c){
  return(gcd(gcd(a,b),c));
}
 
int main(){
  int K;
  cin >> K;
  int count = 0;
  for (int i=1;i<K+1;i++){
    for (int j=1;j<K+1;j++){
      for (int k=1;k<K+1;k++){
        count += gcd3(i,j,k);
      }
    }
  }
  cout << count << endl;
}
        



Measured memory_bytes: 3672
(defun upcase-less-string-p (str)
  (labels ((capital-p (chr)
             (equal (char-upcase chr) chr)))
    (if (characterp str)
        (if (capital-p str)
            nil
            t)
        (if (capital-p (char str 0))
            nil
            (upcase-less-string-p (subseq str 1))))))

(let ((s (coerce (read-line) 'list)))
  (if (and (equal (car s) #\A)
           (equal (count #\C s) 1)
           (< 1 (position #\C s))
           (< (position #\C s) (1- (length s)))
           (eval (cons 'and
                       (mapcar #'upcase-less-string-p
                               (append (subseq s 1 (position #\C s))
                                       (subseq s (1+ (position #\C s))))))))
      (princ "AC")
      (princ "WA")))

Measured memory_bytes: 15720
#include <stdio.h>

int main(int argc,const char * arg[])
{
    int a, b, c, t, count=0;
    
    scanf("%d %d %d",&a,&b,&c);
    
    for(t=a;t<b+1;t++){
        if(c<t)break;
        if(c%t==0)count++;
    }
    printf("%d\n",count);
    
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int>v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  vector<int>dp(n,INT_MAX);
  dp[0]=0;
  dp[1]=abs(v[1]-v[0]);
  for(int i=2;i<n;i++)
  {
    for(int j=1;j<=k;j++)
    {
      if(i-j>=0)
      {
        dp[i]=min(dp[i],abs(v[i]-v[i-j])+dp[i-j]);
      }
      else
       break;
    }
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

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

vector<string> ans;

void rec(int k, int ma, string cur) {
  if (k == ma) {
    ans.emplace_back(cur);
    return;
  }
  int last;
  if (cur.size() == 0) {
    REP(i, 1, 10) {
      rec(k+1, ma, cur+(char)('0'+i));
    }
  } else {
    last = cur[cur.size()-1] - '0';
    if (last == 0) {
      rec(k+1, ma, cur+'0');
      rec(k+1, ma, cur+'1');
    } else if (last == 9) {
      rec(k+1, ma, cur+'8');
      rec(k+1, ma, cur+'9');
    } else {
      rec(k+1, ma, cur+(char)('0'+last-1));
      rec(k+1, ma, cur+(char)('0'+last));
      rec(k+1, ma, cur+(char)('0'+last+1));
    }
  }
}

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

  REP(i, 1, 11) {
    rec(0, i, "");
  }

  print(ans[k-1]);

  return 0;
}

Measured memory_bytes: 13936
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;

const int MOD=1000000007;
ll fac[1000000], finv[1000000], inv[1000000];

void cominit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll choose(int n,int m){
    return fac[n+m] * (finv[n] * finv[m] % MOD) % MOD;
}

int main(){
    ll x,y;
    cin >> x >> y;
    ll s = x+y;
    if(s%3!=0){
        cout << 0 << endl;
        return 0;
    }
    s /= 3;
    x -= s;
    y -= s;
    if(x<0 || y<0){
        cout << 0 << endl;
        return 0;
    }
    cominit();
    ll ans = choose(x,y);
    cout << ans << endl;

}

Measured memory_bytes: 23680
/****Author: ABHIMANYU****/
#include <bits/stdc++.h>

using namespace std;

void solve(){
	string s;
	cin >> s;
	int count=0;int ans =0;
	for(int i=0;i<s.length();i++){
		if(s[i] == 'R'){
			count++;
			ans = max(count,ans);
		}
		else{
			count =0;
		}
	}
	cout << ans << endl;
}


int main(){
/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif*/
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
  bool b = false;
  int A, B, C;
  cin >> A >> B >> C;
  for (int i = 1; i <= B; i++) {
    if (A * i % B == C) {
      b = true;
      break;
    }
  }
  if (b) {cout << "YES" << endl;}
  else {cout << "NO" << endl;}
}

Measured memory_bytes: 3600
import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)
n,q=map(int,input().split())
cnt=[0]*(n)
edges=[0]*n
for i in range(n):
    edges[i]=[]
for i in range(n-1):
    a,s=map(int,input().split())
    edges[a-1].append(s-1);edges[s-1].append(a-1)

from collections import deque
dq=deque([])
#pop/append/(append,pop)_left/in/len/count/[]/index/rotate()(右へnずらす)
for i in range(q):
    p,x=map(int,input().split())
    cnt[p-1]+=x

for i in edges[0]:
    dq.append((0,i))
while dq:
    f,t=dq.popleft()
    cnt[t]+=cnt[f]
    for to in edges[t]:
        if to!=f:dq.append((t,to))
    
print(*cnt)

Measured memory_bytes: 93648
import sys


def input(): return sys.stdin.readline().strip()


def resolve():
    H, W = map(int, input().split())
    l = [list(input()) for i in range(H)]
    cl = [[0] * W for i in range(H)]
    for h in range(H):
        for w in range(W):
            if l[h][w] == '#':
                cl[h][w]='#'
                for j, k in ([1,-1],[1, 0],[1,1], [-1,-1],[-1, 0],[-1,1], [0, 1], [0, -1]):
                    nh, nw = h + j, w + k
                    if nh < 0 or nh >= H or \
                            nw < 0 or nw >= W:
                        continue
                    else:
                        if cl[nh][nw]!='#':
                            cl[nh][nw]+=1
    for h in range(H):
        ans=''
        for x in cl[h]:
            ans+=str(x)
        print(ans)
resolve()

Measured memory_bytes: 42352
#[allow(unused_imports)]
use std::cmp;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use itertools::Itertools;

#[fastout]
fn main() {
  input! {
    n: i64,
  }
  let mut sum = 0;
  for i in 1 ..= n {
    if i % 3 != 0 && i % 5 != 0 {
      sum += i;
    }
  }

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


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



int main(){
	int n;
	cin>>n;
	int x[2*n];
	for(int i=0; i<2*n; i++){
		cin>>x[i];
	}
	sort(x,x+2*n);
	bool flag=1;
	int ans=0;
	for(int i=0; i<2*n; i++){
		if(flag){
			ans+=x[i];
			flag^=1;
		}
		else flag^=1;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
N,M,X = map(int,input().split())
li = []
import numpy as np
C = []

for _ in range(N):
    c,*a = map(int,input().split())
    li.append(np.array(a))
    C.append(c)

counter = []

for i in range(1<<N):
    skill_li = np.zeros(M).astype(int)
    sum_price = 0
    for k in range(N):
        if (i>>k) & 1:
            skill_li += li[k]
            sum_price += C[k]
    if all(skill_li>=X):
        counter.append(sum_price)

if len(counter)==0:
    print(-1)
else:
    print(min(counter))

Measured memory_bytes: 27388
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    if(a == 1 && b != 1) {
        cout << "Alice" << endl;
    } else if(a != 1 && b == 1) {
        cout << "Bob" << endl;
    } else if(a == b) {
        cout << "Draw" << endl;
    } else {
        if(a > b) cout << "Alice" << endl;
        else cout << "Bob" << endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main() {
    int n;
    string s;
    cin >> n >> s;
    sort(s.begin(), s.end());
    vector<int>v;
    v.push_back(1);
    rep(i, 1, n){
        if(s[i]==s[i-1])v.back()++;
        else v.push_back(1);
    }
    ll ans = 1;
    rep(i, 0, v.size()){
        ans *= (v[i]+1);
        ans %= mod;
        //cout << v[i] << endl;
    }
    cout << (ans+mod-1)%mod << endl;
}

Measured memory_bytes: 512
s=input()
if len(s)%2!=0:
  print('No')
  exit()
else:
  if s=='hi':
    print('Yes')
    exit()
  if s=='hihi':
    print('Yes')
    exit()
  if s=='hihihi':
    print('Yes')
    exit()
  if s=='hihihihi':
    print('Yes')
    exit()
  if s=='hihihihihi':
    print('Yes')
    exit()
  else:
    print('No')

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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i=0; i<n; i++) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());

    int ans = 1;
    for (int i=1; i<n; i++) {
        if (d.at(i) > d.at(i-1)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,x;
    cin >> n;
    int *arr=new int[n];
    for(int i=0;i<n;i++){
        cin >> x;
        arr[i]=x;
    }
    int sum=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum+= arr[i]*arr[j];
        }
    }

    cout << sum ;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T1, typename T2> 
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll ans = 0;
  FOR(b, 1, 1000) {
    ll tmp = b;
    FOR(p, 2, 10) { 
      tmp *= b;
      if (tmp <= n) chmax(ans, tmp);
      else
        break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
void shellSort(int *,int);
void insertSort(int *,int,int,int *);
int main(){
  int n,i,j,cut,v,k,m;
  int *array;
  scanf("%d",&n);
  array = malloc(sizeof(int)*n);
  for(i=0;i<n;i++)scanf("%d",&array[i]);
  shellSort(array,n);
  for(i=0;i<n;i++)printf("%d\n",array[i]);
  free(array);
  return 0;
}

void shellSort(int *array,int n){
  int cnt = 0,m,i;
  int *G;
  G = malloc(sizeof(int)*n);
  G[0]=1;
  for(i=1;1;i++){
    if(3*G[i-1]+1 < n)G[i] = 3*G[i-1]+1;
    else break;
  }
  m = i-1;
  for( i = m;i>=0;i--){
    insertSort(array,n,G[i],&cnt);
  }
  printf("%d\n",m+1);
  for(i=m;i>=0;i--){
    if(i != 0)printf("%d ",G[i]);
    else printf("%d\n",G[i]);
  }
  printf("%d\n",cnt);
  free(G);
}

void insertSort(int *A,int n,int g,int *cnt){
  int i,v,j;
  for(i=g;i<n;i++){
    v = A[i];
    j = i - g;
    while( j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j = j-g;
      (*cnt)++;
    }
    A[j+g] = v;
  }
}
  
  
    
  
		
  
  
  



Measured memory_bytes: 5484
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
struct edge{int to,cost,teki;};
typedef pair<int,int> P;
int n,m,l,inf=1e8;
int d[10100];
vector<edge> G[100];
void dijkstra(int s){
	rep(i,n*101) d[i]=inf;
	d[s]=0;
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,s));
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v=p.sc,vn=v/101,vl=v%101;
		if(d[v]<p.fs) continue;
		rep(i,G[vn].size()){
			edge e=G[vn][i];
			int nn=e.to;
			if(d[nn*101+vl]>d[v]+e.teki){
				d[nn*101+vl]=d[v]+e.teki;
				que.push(P(d[nn*101+vl],nn*101+vl));
			}
			if(vl>=e.cost){
				int nl=vl-e.cost,to=nn*101+nl;
				if(d[to]>d[v]){
					d[to]=d[v];
					que.push(P(d[to],to));
				}
			}
		}
	}
}
int main(){
	while(true){
		cin>>n>>m>>l;
		if(n==0) break;
		rep(i,n) G[i].clear();
		rep(i,m){
			int a,b,d,e;
			cin>>a>>b>>d>>e;
			a--,b--;
			G[a].pb({b,d,e});
			G[b].pb({a,d,e});
		}
		dijkstra(l);
		int ans=inf;
		rep(i,l+1) ans=min(ans,d[(n-1)*101+i]);
		cout << ans <<endl;
	}
}

Measured memory_bytes: 1756
def judge(Str, Len):
  if Str[:Len//2] == Str[Len//2:]:
    return True
  else:
    return False

S = input()
L = len(S)
i = 2 - (L % 2)
S = S[:-i]
L -= i
if judge(S, L):
  print(L)
else:
  while not judge(S, L):
    S = S[:-2]
    L -= 2
  print(L)

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

int convert(char c) {
	return (
		c == 'R' ? 0 :
		c == 'G' ? 1 :
		2);
}

int main() {
	int n;
	std::string s;
	std::cin >> n >> s;

	if (n <= 2) {
		std::cout << 0 << std::endl;
		return 0;
	}

	std::vector<int> fwd[3];
	std::vector<int> bck[3];
	for (auto&& v : fwd)
		v.resize(n);
	for (auto&& v : bck)
		v.resize(n);

	fwd[convert(s[0])][0] = 1;
	bck[convert(s.back())].back() = 1;
	for (int i = 1; i < n; ++i) {
		fwd[convert(s[i])][i] = 1;
		for (auto&& v : fwd)
			v[i] += v[i - 1];
		
		bck[convert(s[n - 1 - i])][n - 1 - i] = 1;
		for (auto&& v : bck)
			v[n - 1 - i] += v[n - i];

	}

	std::int64_t ans = 0;
	for (int j = 1; j < n - 1; ++j) {
		int c = convert(s[j]);

		ans += fwd[(c + 1) % 3][j - 1] * bck[(c + 2) % 3][j + 1];
		ans += fwd[(c + 2) % 3][j - 1] * bck[(c + 1) % 3][j + 1];

		for (int d = 1; d <= j && j + d < n; ++d)
			if (s[j - d] != s[j] && s[j] != s[j + d] && s[j + d] != s[j - d])
				--ans;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 3256
#include <stdio.h>
int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580