akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#define N 300005
using namespace std;
typedef long long ll;
ll mod = 1000000007LL;
ll h,w,a,b;
ll comb1[N], comb2[N];
ll getpw(ll x) {
  ll res=1LL;
  ll b = mod-2;
  while(b) {
  	if (b&1) res = res*x%mod;
    x = x*x%mod;
    b /= 2;
  }
  return res;
}
void calc(ll* comb, int n) {
  comb[0]=1LL;
  ll up = 1LL;
  ll down = 1LL;
  for (int i = 1; i <= n; ++i) {
  	up = up * (ll)(n- (i-1)) % mod;
    down = down * (ll)i % mod;
    comb[i] = up * getpw(down) % mod;
  }
}
int main() {
  cin>>h>>w>>a>>b;
  memset(comb1, 0, sizeof(comb1));
  memset(comb2, 0, sizeof(comb2));
  calc(comb1, h-a+b-1);
  calc(comb2, a-b+w-1);
 // cout<<comb1[0]<<" "<<comb2[1]<<endl;
  ll ans=0LL;
  for (int i= 0; i < h-a; ++i) {
  	ans = (ans + comb1[i]*comb2[h-1-i]%mod)%mod;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
#define int lint
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
signed main(){
    int n;
    cin >> n;
    vector<P> v(n);
    rep(i,n){
        int a, b;
        cin >> a >> b;
        v[i].first = b;
        v[i].second = a;
    }
    sort(all(v));
    int t = 0;
    rep(i, n)
    {
        if(t+v[i].second<=v[i].first){
            t = t + v[i].second;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
//#include<bits/stdc++.h>
#include<cstring>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
//ll a,b,c,x,y;

ll ex_gcd(ll a,ll b,ll& x,ll& y)
{
    if(b==0)
    {
        x=1;
        y=0;
        return a;
    }
    ll ans = ex_gcd(b,a%b,x,y);
    ll tmp = x;
    x = y;
    y = tmp-a/b*y;
    return ans;
}
map<int,pair<int,int> >mp;
map<int,int>m;
int x;
int a[4][4];
int b[4][4];
int main()
{

    memset(b,0,sizeof(b));
    for(int i=1; i<=3; i++)
        for(int j=1; j<=3; j++)
        {
            scanf("%d",&x);
            m[x]=1;
            mp[x].first=i;
            mp[x].second=j;
        }
    int k;
    scanf("%d",&k);
    int c,d;
    while(k--)
    {
        scanf("%d",&x);
        if(m[x])
        {
            c=mp[x].first;
            d=mp[x].second;
            b[c][d]=1;
        }
    }

    for(int i=1; i<=3; i++)
    {
        if(b[i][1]&&b[i][2]&&b[i][3])
        {

            printf("Yes\n");
            return 0;
        }
    }
    for(int i=1; i<=3; i++)
    {
        if(b[1][i]&&b[2][i]&&b[3][i])
        {

            printf("Yes\n");
            return 0;
        }
    }
    if(b[1][1]&&b[2][2]&&b[3][3])
    {

        printf("Yes\n");
        return 0;
    }
    if(b[1][3]&&b[2][2]&&b[3][1])
    {

        printf("Yes\n");
        return 0;
    }
    printf("No\n");
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

int main() {
	map<int, int> m;

	for (int i = 0; i < 3; i++) {
		int a;
		cin >> a;
		m[a]++;
	}

	cout << (m[5] == 2 && m[7] == 1 ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
#define ll long long
#define ld long double
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll po(ll base, ll powerRaised)
{
    if (powerRaised != 0)
        return (base * po(base, powerRaised - 1));
    else
        return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif //*/
    string s;

    cin >> s;
    string p = s;
    ll n = s.length();
    string a = s.substr(0, (n - 1) / 2);
    string b = s.substr((n + 3) / 2 - 1, (n - 1) / 2);
    string c = a;
    string d = b;
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    reverse(s.begin(), s.end());
    // cout << p << " " << s;
    if (c == a && d == b && p == s)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


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



int main() {
  int H, W;
  char s[101][101] = {};
  cin >> H >> W;
  int dp[102][102];
  for (int i=0;i<102;i++){
    for(int j=0;j<102;j++){
      dp[i][j]=H+W-2;
    }
  }

  //入力
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> s[i][j];
    }
  } 
  if(s[1][1]=='#'){
    dp[1][1]=1;
  } 
  else dp[1][1]=0;
  
  for (int j=1;j<=W;j++){
    if((s[1][j]=='.')&&(s[1][j+1]=='#')){
      dp[1][j+1]=min(dp[1][j+1],dp[1][j]+1);
    }
    else dp[1][j+1]=min(dp[1][j+1],dp[1][j]);
   if((s[1][j]=='.')&&(s[2][j]=='#')){
     dp[2][j]=min(dp[2][j],dp[1][j]+1);
   }
    else dp[2][j]=min(dp[2][j],dp[1][j]);
  }
  
  for(int i=2;i<=H;i++){  
    for(int j=1;j<=W;j++){
      if((s[i][j]=='.')&&(s[i][j+1]=='#')){
        dp[i][j+1]=min(dp[i][j+1],dp[i][j]+1);
      }
      else dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
      
      if((s[i][j]=='.')&&(s[i+1][j]=='#')){
        dp[i+1][j]=min(dp[i+1][j],dp[i][j]+1);
      }
      else dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
    }
  }
  
  
  cout<<dp[H][W]<<endl;
  
	return 0;
}

Measured memory_bytes: 256
import math
a=int(input())
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table
print(sum(num_divisors_table(a-1)))    

Measured memory_bytes: 16584
n,m = [int(i) for i in input().split()]
p = [0]*m
s = [False]*m
for i in range(0,m):
    p[i],s[i] = input().split()
    p[i] = int(p[i])
    s[i] = (s[i] == 'AC')
ac = [False]*(n+1)
numWA = [0]*(n+1)
numAC = 0
for i in range(0,m):
    if not(s[i]) and not(ac[p[i]]):
        numWA[p[i]] += 1
    elif s[i] and not(ac[p[i]]):
        numAC += 1
        ac[p[i]] = True
sumWA = 0
for i in range(1,n+1):
    if ac[i]:
        sumWA += numWA[i]

print(str(numAC) + ' ' + str(sumWA))

Measured memory_bytes: 9348
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K;
	cin >> N >> K;

	VI A(N);
	REP(i, N) {
		cin >> A[i];
	}

	int ans = 0;
	int t = K * (K - 1) / 2;
	int tt= K * (K + 1) / 2;
	REP(i, N) {
		//int cnt = 0;
		//int tmp = 0;

		FOR(j, i + 1, N) {
			if (A[i] > A[j])ans += tt;
			else if (A[i] != A[j])ans += t;
			ans %= mod;
		}


		//ans += tmp * t;
		//ans %= mod;a
		//cout << cnt << " " << tmp << endl;
	}
	
	cout << ans << endl;
	return 0;
}



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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> vv (H + 2, vector<char> (W+2));
  for (int i = 0; i < H + 2; i++) {
    for (int j = 0; j < W + 2; j++) {
      if(i == 0 || i == H+1 || j == 0 || j == W+1) {
        vv.at(i).at(j) = '.';
      }
      else {
        char c;
        cin >> c;
        vv.at(i).at(j) = c;
      }
    }
  }
  for (int i = 1; i < H+1; i++) {
    for (int j = 1; j < W + 1; j++) {
      if (vv.at(i).at(j) =='.') {
      int cnt = 0;
      if (vv.at(i+1).at(j) == '#') cnt++;
      if (vv.at(i+1).at(j-1) == '#') cnt++;
      if (vv.at(i+1).at(j+1) == '#') cnt++;
      if (vv.at(i).at(j-1) == '#') cnt++;
      if (vv.at(i).at(j+1) == '#') cnt++;
      if (vv.at(i-1).at(j) == '#') cnt++;
      if (vv.at(i-1).at(j+1) == '#') cnt++;
      if (vv.at(i-1).at(j-1) == '#') cnt++;
      char d = '0' + cnt;
      vv.at(i).at(j) = d;
      }
    }
  }
  for (int i = 1; i < H+1; i++) {
    for (int j = 1; j < W+1; j++) {
      cout << vv.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
        n:i64,
    }
    let mut n = n;
    if n == 2 {
        println!("{}", 1);
        return;
    }
    let mut ans = 0;
    let mut divs = divisor((n - 1) as usize);
    ans += divs.len() - 1;
    let mut dvs2 = divisor(n as usize);
    for &d in dvs2.iter() {
        if d == 1 {
            continue;
        }
        let mut m = n as usize;
        while m % d == 0 {
            m /= d;
        }
        if m % d == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}
pub fn divisor(n: usize) -> Vec<usize> {
    let mut res = Vec::new();
    for i in (1..).take_while(|x| x * x <= n) {
        if n % i == 0 {
            res.push(i);
            if i != n / i {
                res.push(n / i);
            }
        }
    }
    res.sort();
    res
}


Measured memory_bytes: 2180
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val x, a = s.nextInt
    if (x < a) "0" else "10"
  }

  val tests = List(
    """3 5""".stripMargin -> """0""",
    """7 5""".stripMargin -> """10""",
    """6 6""".stripMargin -> """10"""
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

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

using namespace std;

#define FastIO ios_base :: sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read(in) freopen("Input.txt","r",stdin)
#define write(out) freopen("Ouput.txt","w",stdout)
#define pf printf
#define sf scanf
#define fr(i,n) for(i=1 ; i<=n ; i++)
#define fr1(i,x,n) for(i=x ; i<=n ; i++)
#define sf1(val) scanf("%lld",&val)
#define sf2(val1,val2) scanf("%lld %lld",&val1,&val2)
#define INF 999999999999999999
#define Pi 2*acos(0.0)
#define len 200000

typedef long long int lli;

lli a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,sum=0,total=0,res=0,ans=0;

int main()
{
    //FastIO;

    //read(in);
  
  	sf2(n,k);
  
  	vector<lli>ar;
  	
  	fr(i,n)	sf1(x) , ar.push_back(x);
  
  	sort(ar.begin(),ar.end());
  
  	fr(i,k)	sum+=ar[i-1];
  
  	pf("%lld\n",sum);
}

Measured memory_bytes: 3752
#include<iostream>
using namespace std;
const int maxnum = 100000;
int n; //the number of number
int Array[maxnum];
int main()
{
    cin>>n;
    int y_max;
    int y_min;
    long y_sum;
    for (int i = 0 ; i < n ; i++)
    {
        cin>>Array[i];
    }
    y_max = Array[0] ;
    y_min = Array[0];
    y_sum = 0;
    for (int y=0;y<n;y++)
    {
        if(y_min < Array[y])
        {
        }
        else
            y_min = Array[y];
    }
    for (int z=0;z<n;z++)
    {
        if(y_max > Array[z])
        {
        }
        else
            y_max = Array[z];
     
    }
    for (int m=0;m<n;m++)
    {
        y_sum +=  Array[m];
    }
    cout<<y_min<<' '<<y_max<<' '<<y_sum<<endl;
    return 0;
}

Measured memory_bytes: 3088
fun main(args: Array<String>) {
  val N = readString().map { it.toString().toInt() }
  val K = readInt()

  val dp = Array(N.size + 1) { Array(K + 1) { 0 } }
  val fg = Array(N.size + 1) { Array(K + 1) { 0 } }
  fg[0][0] = 1
  for (i in 1..N.size) {
    val n = N[i - 1]
    // 確定からの遷移
    for (j in 0..K) dp[i][j] += dp[i - 1][j] // 確定 → 0
    for (j in 1..K) dp[i][j] += dp[i - 1][j - 1] * 9 // 確定 → 1~9
    // 未確定からの遷移
    if (n > 0) {
      for (j in 0..K) dp[i][j] += fg[i - 1][j] // 未確定 → 0
      for (j in 1..K) dp[i][j] += fg[i - 1][j - 1] * (n - 1) // 未確定 → 1~(n-1)
      for (j in 1..K) fg[i][j] += fg[i - 1][j - 1] // 未確定 → n
    } else {
      for (j in 1..K) fg[i][j] += fg[i - 1][j] // 未確定 → 未確定
    }
  }

  println(dp[N.size][K] + fg[N.size][K])
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


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

int main() {
	int n, d;
	cin>>n>>d;
	vector<vector<int>> X(n, vector<int>(d));
	rep(i, n) {
		rep(j, d) cin >> X[i][j];
	}

	int ans = 0;

	// for (int i = 0; i < n; i++) {
	// 	for (int j = 0; j < i; j++) {
			
	// 	}
	// }

	
	rep(i, n)rep(j, i) { //j < i
		int sq = 0;
		rep(k, d) {
			int s = X[i][k] - X[j][k];
			sq += s*s;
		}
		int s = sqrt(sq) + 0.5;
		if (s*s == sq) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
number_str=input("")
number=int(number_str)

tr=[]
mark=["S","H","C","D"]
for j in mark:
    for i in range(1,14):
        u=j+" "+str(i)
        tr.append(u)

array=[]
nomatch=[]
i=1
while i<=number:
    x=input()
    array.append(x)
    i=i+1
  
for i in tr:
    if i not in  array:
        nomatch.append(i)
 
for i in nomatch:
    print(i)


Measured memory_bytes: 5596
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	int ans = 1000;
	for (int i = 2; i < s.size(); ++i) {
		ans = min(ans, abs(753 - stoi(s.substr(i - 2, 3))));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
int A,B,C;
cin >> A >> B >> C;
int count =0;
while(1){
  B -= A;
  if(count == C){
    break;
  }
  if(B < 0){

    break;
  }
  count++;


}
cout << count << endl;
}


Measured memory_bytes: 256
#include <cstdio>
int main()
{

		char a;
		scanf ("%c",&a);
		if (a-32 == 'A'||a-32 == 'E'||a-32 == 'I'||a-32 == 'O'||a-32 == 'U'){
		printf ("vowel\n");}
		else printf ("consonant\n");
	return 0;
	}

Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define int long long
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int N, sum = 0;
	cin >> N;
	vector <int> L(N);
	rep(i, N) {
		cin >> L[i];
		sum += L[i];
	}
	sort(ALL(L));
	if (2 * LAST(L) < sum)
		cout << "Yes";
	else
		cout << "No";
}

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

int main(){
    int N,colorvalu=0,color=0;
    cin>>N;
    vector<int> a(N);
    bool gray = false,brown=false,green=false,skyblue=false;
    bool blue = false,yellow=false,orange=false,red=false;
    for(int i=0;i<N;i++){
        cin>>a.at(i);
        if(a.at(i)>=1&&a.at(i)<=399){
            gray = true;
        }else if(a.at(i)>=400&&a.at(i)<=799){
            brown = true;
        }else if(a.at(i)>=800&&a.at(i)<=1199){
            green = true;
        }else if(a.at(i)>=1200&&a.at(i)<=1599){
            skyblue = true;
        }else if(a.at(i)>=1600&&a.at(i)<=1999){
            blue = true;
        }else if(a.at(i)>=2000&&a.at(i)<=2399){
            yellow =true;
        }else if(a.at(i)>=2400&&a.at(i)<=2799){
            orange = true;
        }else if(a.at(i)>=2800&&a.at(i)<=3199){
            red = true;
        }else{
            colorvalu ++;
        }
    }
    if(gray){
        ++color;
    }if(brown){
        ++color;
    }if(green){
        ++color;
    }if(skyblue){
        ++color;
    }if(blue){
        ++color;
    }if(yellow){
        ++color;
    }if(orange){
        ++color;
    }if(red){
        ++color;
    }
    if(color!=0){
    cout<<color<<" "<<color+colorvalu<<endl;
    }else{
        cout<<1<<" "<<colorvalu<<endl;
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(A: int, op: str, B: int):
    if op == '+':
        ret = A + B
    else:
        ret = A - B
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    op = next(tokens)  # type: str
    B = int(next(tokens))  # type: int
    solve(A, op, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n,k =map(int,input().split())
A =list(map(int,input().split()))
plus=[0]*(n)
C=[0]*2001
for i in range(n):
	for j in range(A[i]):
		C[j]+=1
# print(C[:5])
	plus[i]=C[A[i]]
count=0
for i in range(n):
	count+=plus[i]*(k)
	# print(count)
	count+=C[A[i]]*k*(k-1)//2
	count=count%(10**9+7)
# 	print(count)
# print(plus)
# print(C[:5])
print(count)





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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li a,b,c;

    cin>>a>>b>>c;

    swap(a,b);
    swap(a,c);

    cout<<a<<" "<<b<<" "<<c;

    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader stdReader = new BufferedReader(new InputStreamReader(
				System.in));
		String line = stdReader.readLine();
		String[] tokens = line.split(" ");
		int x = Integer.parseInt(tokens[0]);
		int y = Integer.parseInt(tokens[1]);

		System.out.println((x * y) + " " + (x + y) * 2);

	}

}


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

typedef long long ll;
int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> v(n+1), a(n+1, 0), b(n+1, 0);
    for(int i=1;i<n+1;i++) cin >> v[i];

    for(int i=1;i<n+1;i++) {
        a[i] += v[i] + a[i-1];
    }
    for(int i=1;i<n+1;i++) {
        if(v[i] > 0)
            b[i] += v[i] + b[i-1];
        else
            b[i] = b[i-1];
    }

    ll ans = -1e15;
    for(int i=1;i <= n - k + 1;i++) {
        ll ans_i = 0;
        ll k_range_sum = a[i+k-1] - a[i-1];

        ans_i += max<ll>(k_range_sum, 0);
        ans_i += b[i-1];
        ans_i += (b[n] - b[i+k-1]);
        ans = max<ll>(ans, ans_i);
    }

    cout << ans << endl;
}


Measured memory_bytes: 2560
#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;

int MOD;

void sadd(int &a, int b)
{
    a += b;
    if (a >= MOD)
        a -= MOD;
}
int add(int a, int b)
{
    sadd(a, b);
    return a;
}
int mul(int a, int b)
{
    return (a * 1LL * b) % MOD;
}

const int N = 6100;

int dp[N][N];

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

    int n;
    scanf("%d%d", &n, &MOD);


    dp[0][0] = 1;

    for (int i = 0; i <= 3 * n; i++)
        for (int j = 0; j <= 2 * n; j++)
        {
            int cur = dp[i][j];
            if (cur == 0)
                continue;
            //eprintf("(%d, %d) : %d\n", i, j, cur);
            sadd(dp[i + 1][j], cur);
            cur = mul(cur, i + 1);
            sadd(dp[i + 2][j + 2], cur);
            cur = mul(cur, i + 2);
            sadd(dp[i + 3][j + 2], cur);
        }


    int ans = 0;
    for (int i = 0; i <= 2 * n; i++)
        sadd(ans, dp[3 * n][i]);

    printf("%d\n", ans);

	return 0;
}




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

int n, a[100], ta = 0;

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


Measured memory_bytes: 3088
a,b,c,d=map(int, input().split())
ans=-10**20
ans=max(a*c,ans)
ans=max(a*d,ans)
ans=max(b*c,ans)
ans=max(b*d,ans)
if a<=0<=b or c<=0<=d: ans=max(0,ans)
print(ans)

Measured memory_bytes: 61612
R, G, B, N = list(map(int, input().split()))

max_r = N // R
max_g = N // G
max_b = N // B

count = 0
for r in range(max_r + 1):
    for g in range(max_g + 1):
        now_n = r * R + g * G
        if now_n <= N and (N - now_n) % B == 0:
            b = (N - now_n) // B
            count += 1

ans = count

print(ans)

Measured memory_bytes: 40940
// "for if God is with them who can be against them."
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define endl '\n'
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
void solve() {
	int a;
	cin >> a;
	cout << a + (a * a) + (a * a * a);
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	IOS;
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}


#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#define MAX 2000000

int Si, M[MAX+1];

void maxHeapify(int i){
  int o, t, largest, e;
  o = 2*i;
  t = 2*i+1;
  if ( o <=Si && M[o] > M[i] ) largest = o;
  else largest = i;
  if ( t <= Si && M[t] > M[largest] ) largest = t;
  if ( largest != i ){
    e = M[i]; M[i] = M[largest]; M[largest] = e;
    maxHeapify(largest);
  }
}

main(){
  scanf("%d", &Si);
  int i;
  for ( i =1; i<=Si;i++ ) scanf("%d", &M[i]);
  
  for (i=Si/2;i>=1;i-- ) maxHeapify(i);

  for (i=1;i<=Si;i++) {
    printf(" %d", M[i]);
  }
  printf("\n");
  

  
  return 0;
}



Measured memory_bytes: 3760
#include <stdio.h>

int sq(int x, int y);

int main(void) {
  int x, i, j, max = 0, number;

  scanf("%d", &x);

  for (i = 2; i < 32; i++) {
    for (j = 3; j < 10; j++) {
      if ((x < sq(i,j)) && (x >= sq(i,j-1))) {
        number = sq(i,j-1);
        if (max < number) {
          max = number;
        }
        break;
      }
    }
  }

  if (max == 0) {
    max = 1;
  }

  printf("%d\n", max);

  return 0;
}

int sq(int x, int y) {
  if (y > 0) {
    return (x * sq(x, y-1));
  }else {
    return 1;
  }
}

Measured memory_bytes: 128
def main():    
    s = input()
    ans = "Yes"
    for i in range(len(s)):
        if i%2 == 1 and s[i] == "R":
            ans = "No"
        elif i%2 == 0 and s[i] =="L":
            ans = "No"
    print(ans)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
import sys
az =["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
sum_az = [0 for x in range(26)]

for x in sys.stdin.read().lower():
    for i in range(26):
        for j in range(len(x)):
            if x[j] == az[i]:
                sum_az[i] += 1


for i in range(26):
    print ("%s : %d" % (az[i], sum_az[i]))
                

Measured memory_bytes: 4236
let () = Scanf.scanf "%d\n" @@ fun n ->
  let ps = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun p -> p in
  let acc = Array.make (n + 1) max_int in
  for i = 0 to n - 1 do
    acc.(i + 1) <- min ps.(i) acc.(i)
  done;
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0 @@
  Array.init n @@ fun i ->
    if ps.(i) <= acc.(i) then 1 else 0


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

using namespace std;
const int MOD = 1000000007;
string dec(string s){
    for(int i = s.size() - 1; i >= 0; i--){
        if(s[i] == '0'){
            s[i] = '9';
        }else{
            s[i] = s[i] - 1;
            if(i == 0 && s[i] == '0'){
                s = s.substr(1);
            }
            break;
        }
    }
    return s;
}
void add(int& x, int y){
    x = (x + y) % MOD;
}
int solve(string s, string t){
    const int MAX_N = 10010;
    const int MAX_L = 510;

    int n = s.size();
    int m = t.size();
    // printf("s = %s t = %s\n", s.c_str(), t.c_str());
    // printf("n = %d m = %d\n", n, m);

    int next[MAX_L][10] = {};
    for(int i = 0; i <= m; i++){
        for(int c = 0; c < 10; c++){
            string r = t.substr(0, i) + string(1, '0' + c);
            for(int len = r.size(); len >= 0; len--){
                if(r.substr(r.size() - len, len) == t.substr(0, len)){
                    next[i][c] = len;
                    break;
                }
            }
        }
    }

    static int count[MAX_N][MAX_L][2] = {};
    static int match[MAX_N][MAX_L][2] = {};
    memset(count, 0, sizeof(count));
    memset(match, 0, sizeof(match));
    for(int i = 0; i < n; i++){
        for(int c = (i + 1 < n ? 1 : 0); c <= (i == 0 ? s[i] - '0' : 9); c++){
            int nj = next[0][c];
            int nlw = (i > 0 || c < s[i] - '0');
            add(count[i + 1][nj][nlw], 1);
            if(nj == m){
                add(match[i + 1][nj][nlw], 1);
            }
        }
        for(int j = 0; j <= m; j++){
            for(int lw = 0; lw < 2; lw++){
                for(int c = 0; c <= (lw ? 9 : s[i] - '0'); c++){
                    int nj = next[j][c];
                    int nlw = lw || (c < s[i] - '0');
                    add(count[i + 1][nj][nlw], count[i][j][lw]);
                    add(match[i + 1][nj][nlw], match[i][j][lw]);
                    if(nj == m){
                        add(match[i + 1][nj][nlw], count[i][j][lw]);
                    }
                }
            }
        }
    }
    int ans = 0;
    for(int i = 0; i <= m; i++){
        add(ans, match[n][i][0]);
        add(ans, match[n][i][1]);
    }
    // printf("return %d\n", ans);
    return ans;
}
int main(){
    string a, b, c;
    while(cin >> a >> b >> c){
        int x = solve(b, c);
        int y = (a != "0" ? solve(dec(a), c) : 0);
        cout << (x - y + MOD) % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 81040
import java.util.Scanner;

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

		int cnt = 0;
		char c = 'a';

		for (char s : S.toCharArray()){
			if (s == c){
				cnt++;
			}else {
				cnt = 0;
			}

			if (cnt >= 2){
				System.out.println("Yes");
				return;
			}
			c = s;
		}
		System.out.println("No");
		return;
	}
}


Measured memory_bytes: 22740
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)

a_sum = sum(a)
t = a_sum / (4*m)

cnt = 0
for i in range(n):
    if a[i] >= t:
        cnt += 1
    else :
        break
        
if cnt >= m:
    print("Yes")
else:
    print("No")


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

class Program
{
    public static void Main()
    {
        double[] input = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
        double a = input[0] * 100 / 8, b = input[1] * 10;
        if (a > b)
        {
            if (a < (input[1] + 1) * 10)
            {
                Console.WriteLine(Math.Ceiling(a));
            } else
            {
                Console.WriteLine(-1);
            }
        } else
        {
            if (b < (input[0] + 1) * 100 / 8) {
                Console.WriteLine(Math.Ceiling(b));
            } else
            {
                Console.WriteLine(-1);
            }
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>

int main() {
    std::stack<int> stack_1;
    std::stack<std::pair<int, int>> stack_2;
    char ch;
    int sum = 0;
    for (int i=0; std::cin >> ch; i++) {
        if (ch == '\\')/* then */ stack_1.push(i);
        else if (ch == '/' && stack_1.size() > 0) {
            int j = stack_1.top(); /* and */ stack_1.pop();
            sum += i-j;
            int a = i-j;
            while (stack_2.size() > 0 && stack_2.top().first > j) {
                a += stack_2.top().second; /* and */ stack_2.pop();
            }
            stack_2.push(std::make_pair(j, a));
        }
    }

    std::vector<int> ans;
    while (stack_2.size() > 0) {
        ans.push_back(stack_2.top().second);
        stack_2.pop();
    }
    std::reverse(ans.begin(), ans.end());
    std::cout << sum << std::endl;
    std::cout << ans.size();
    for (int i=0; i<ans.size(); i++) {
        std::cout << " ";
        std::cout << ans[i];
    }
    std::cout << std::endl;
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int  a, b;
double c;
  cin >> a >> b;
if( (a+b) % 2 == 0)   cout << (a+b) / 2 << endl;
else  cout << (a+b) / 2 + 1 << endl;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	int i=0,j=0,k=0,id=0;
	int x=a.size(),y=b.size(),z=c.size();
	while(1){
		if(i==x&&!id) return puts("A"),0;
		else if(j==y&&id==1) return puts("B"),0;
		else if(k==z&&id==2) return puts("C"),0;
		if(!id) id=a[i]-'a',i++;
		else if(id==1) id=b[j]-'a',j++;
		else if(id==2) id=c[k]-'a',k++;
	}
	return 0;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

int main() {
    ll ans = -(LONG_LONG_MAX-1);
    int n;
    cin >> n;

    vl a(n);

    ll sum=0;
    ll cnt=0; //負数の数
    REP(i,n){
        int temp;
        cin>>temp;
        
        if(temp<0) cnt++;
        sum += abs(temp);
        a[i] = abs(temp);
    }

    if(cnt%2==0){
        cout << sum << endl;
        return 0;
    }

    //絶対値の合計sumからある1要素をマイナスにした時の合計を求める
    REP(i,n){
        ans = max(ans, sum-a[i]*2);
    }

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

Measured memory_bytes: 1024
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
k = I()
x = I()
y = I()
ans = 0
for i in range(1, n+1):
    if i<= k:
        ans += x
    else:
        ans += y
print(ans)

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

typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;


//===

const ll mod = static_cast<ll>(1e9 + 7);



int main() {
	int N;
	cin >> N;
	vector<Vi> g(N);
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	Vi c(N);
	for (int i = 0; i < N; ++i) {
		cin >> c[i];
	}

	sort(c.begin(), c.end(), greater<int>());

	Vi nums(N, -1);

	int ans = 0;
	stack<int> s;
	int c_idx = 0;
	s.push(0);
	nums[0] = c[c_idx++];
	while (!s.empty()) {
		int node = s.top();
		s.pop();
		for (const auto& val : g[node]) {
			if (nums[val] != -1) continue;
			nums[val] = c[c_idx++];
			ans += min(nums[node], nums[val]);
			s.push(val);
		}
	}

	cout << ans << endl;
	for (int i = 0; i < N - 1; ++i) {
		cout << nums[i] << " ";
	}
	cout << nums.back() << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define psvi pair<string,vi>
#define psi pair<string,int>
#define pss pair<string,string>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
#define vvi vector<vi>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd 
/****************************/
int main()
{
	int n;
	cin>>n;
	cout<<(n+1)/2;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a=0,b=0;
  char ex;
  while(a == 0){scanf("%d %c %d",&a,&ex,&b);
    if(ex == '+'){printf("%d\n",a+b);
      a = 0;}
    else if(ex == '-'){printf("%d\n",a-b); 
	a = 0;}
    else if(ex == '*'){printf("%d\n",a*b); 
	a = 0;}
    else if(ex == '/'){printf("%d\n",a/b);
        a = 0;}
    else if(ex == '?')break;}
    
    return 0;
   }

Measured memory_bytes: 600
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007
//#define DEBUG

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(array, 10, sizeof(int), compare_int)

int main(){
	int k;
	scanf("%d", &k);

	int i=1, seven=7;
	
	while(i<10000000){
		if(seven%k == 0) break;
		seven = seven * 10 + 7;
		if(seven>k){
			seven = seven%k;
		}
		i++;
	}
	
	if(i == 10000000) i = -1;
	
	printf("%d\n", i);

	
	return 0;
}



Measured memory_bytes: 1732
#include <iostream>
#include <vector>

using namespace std;


#define int_max 0x3f3f3f3f
#define int_min -0x3f3f3f3f

int main()
{
    int n;
    cin >> n;
    int cost = 0;
    int x;
    vector<int> costs(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> x;
        costs.at(i) = x;
    }

    vector<int> dp(n + 1, 0);

    dp[1] = 0;

    if (n > 2)
        dp[2] = min(abs(costs[3] - costs[1]), abs(costs[2] - costs[1]));
    else
        dp[2] = abs(costs[2] - costs[1]);

    for (int i = 1; i <= n; i++)
    {
        if (i == 1 || i == 2)
            continue;

        int x = dp[i - 2] + abs(costs[i] - costs[i - 2]);
        int y = dp[i - 1] + abs(costs[i] - costs[i - 1]);
        dp[i] = min(x, y);
    }

    cout << dp[n] << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int a, b;
	cin >> a >> b;

	if(a + b == 15){
		cout << '+' << endl;
		return 0;
	}

	if(a * b == 15){
		cout << '*' << endl;
		return 0;
	}

	cout << 'x' << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a * 500 >= b){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21716
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ans = 0;
		int ab = a+b;
		int bc = b+c;
		int ca = c+a;
		ans = Math.min(ca, Math.min(ab, bc));
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#pragma warning( disable:4996 )
using namespace std;

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	int r;
	scanf("%d", &r);
	printf("%d\n", r * r);
	return 0;
}

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

using namespace std;

struct key {
	long long cost;
	long long mask;
};

const long long inf = 1e15;

key Keys[1003];
long long d[1003][5000];

int main() {
	ios::sync_with_stdio(false);
	long long n, m;
	cin>>n>>m;
	for (long long i = 1; i <= m; i++) {
		long long k;
		cin>>Keys[i].cost>>k;
		Keys[i].mask = 0;
		for (long long j = 1; j <= k; j++) {
			long long v;
			cin>>v;
			Keys[i].mask += 1<<(v - 1);
		}
	}
	/*for (long long i = 1; i <= m; i++)
		cout<<Keys[i].cost<<" "<<Keys[i].mask<<endl;*/
	for (long long i = 0; i <= m; i++)
	for (long long j = 0; j <= pow(2, 12); j++)
		d[i][j] = inf;
	d[0][0] = 0;
	for (long long i = 0; i < m; i++)
	for (long long j = 0; j < pow(2,12); j++) {
		d[i + 1][j] = min(d[i + 1][j], d[i][j]);
		d[i + 1][j | Keys[i + 1].mask] = min(d[i + 1][j | Keys[i + 1].mask], d[i][j] + Keys[i + 1].cost);
	}
	
	/*for (long long i = 0; i <= m; i++) {
		for (long long j = 0; j < 10; j++)
			cout<<d[i][j]<<" ";
		cout<<endl;
	}*/
	//cout<<d[2][3]<<endl;
	if (d[m][(long long)pow(2, n) - 1] == inf) d[m][(long long)pow(2, n) - 1] = -1;
	cout<<d[m][(long long)pow(2, n) - 1]<<endl;
}


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

#define mx 1000005
#define ll long long 

void IO()
{
     #ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
}

int cnt[mx];
ll ans[mx];
int n,m,k,ii;

void solve()
{
    scanf("%d",&n);
    int boro=0;
    int gc=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        boro=max(boro,x);
        cnt[x]++;
        gc=__gcd(gc,x);
    }
    bool f=true;
    for(int i=boro;i>=1;i--)
    {
        ll tot=0;
        for(int j=i;j<=boro;j+=i)
        {
            tot+=cnt[j];
            ans[i]-=ans[j];
        }
        if(tot<2)            /// if want k length set then use k
        {
            ans[i]=0;
        }
        else
        {
            tot=(tot*(tot-1))/2;  /// if want k length set then  nCk. n=tot;
            ans[i]+=tot;
            if(i>1 && ans[i]>=1)
            {
            	f=false;
            	break;
            }
            
        }
    }
    if(f)printf("pairwise coprime\n");
    else if(gc==1)printf("setwise coprime\n");
    else printf("not coprime\n");
}

int main()
{
	IO();

	int t=1;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 15368
fn main() {
    proconio::input! {
        n: usize,
        s: String,
    }
    let r = s.matches('R').count();
    let g = s.matches('G').count();
    let b = s.matches('B').count();
    let v = s.as_bytes();
    let mut t=r*g*b;
    for i in 0..n { for j in i+1..(n+i+1)/2 {
        let k=j+j-i;
        if v[i]!=v[j]&&v[i]!=v[k]&&v[j]!=v[k] {
            t-=1;
        }
    }}
    println!("{}",t);
}

Measured memory_bytes: 2152
#include <stdio.h>
#define M 1000000007

int main()
{
	int xs, ys;
	int x[100001];
	int y[100001];
	scanf("%d%d", &xs, &ys);
	long i;
	for (i = 0; i < xs; i++)
	{
		scanf("%d", x + i);
	}
	for (i = 0; i < ys; i++)
	{
		scanf("%d", y + i);
	}
	long s = 0;
	long w;
	for (i = 1; i < xs; i++)
	{
		w = i*(xs - i) % M;
		s += (x[i] - x[i - 1]) * w % M;
		s %= M;
	}
	long sum = s;
	s = 0;
	for (i = 1; i < ys; i++)
	{
		w = i*(ys - i) % M;
		s += (y[i] - y[i - 1]) * w % M;
		s %= M;
	}
	printf("%ld\n", sum * s % M);

	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

// mod. m での a の逆元 a^{-1} を計算する
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll com (ll n, ll r){
    ll res = 1;
    for(ll i = 0; i < r; i++) {
        res *= (n-i) % MOD;
        res %= MOD;
        res *= modinv((i+1), MOD); // 割り算は逆元を掛ける。
        res %= MOD;
        // cout << r << " " << res << endl;        
    }
    return res % MOD;
}

int main() {

    ll n, a, b;
    cin >> n >> a >> b;

    ll ans = modpow((ll)2, n, MOD);
    // cout << ans << endl;
    
    ans -= (com(n, a) + com(n, b) + 1) % MOD;
    // cout << com(n, a) << " " << com(n, b) << endl;
    
    ans %= MOD;
    if (ans < 0) ans += MOD; 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int dir[4][2]={ {1,0},{0,1},{-1,0},{0,-1} };

int map[100][100]={};
int gone[100][100]={};
int w,h,ans=0;

void rec(int x,int y,int dep){
	ans=(ans<dep?dep:ans);
	gone[x][y]=1;
	for(int i=0;i<4;i++){
		int nx = x +dir[i][0];
		int ny = y +dir[i][1];{
		if(!(nx<=0 || ny<=0 || nx>w || ny>h || map[nx][ny]==0 || gone[nx][ny]==1))
			rec(nx,ny,dep+1);}
	}
	gone[x][y]=0;
}

int main(void){
while(1){
	scanf("%d%d", &w, &h);
	if(!w)break;
	ans=0;
	for(int y=1;y<=h;y++)
		for(int x=1;x<=w;x++)
			scanf("%d", &(map[x][y]));

	for(int y=1;y<=h;y++)
		for(int x=1;x<=w;x++)
			if(map[x][y]==1)rec(x,y,1);

	printf("%d\n",ans);
}
	return 0;
}
	

Measured memory_bytes: 1092
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a <= 8 && b <= 8 ? "Yay!" : ":(") << endl;

    return 0;
}


Measured memory_bytes: 256
#B問題
S=str(input())
Slist=list(S)
Slen=len(Slist)
MAX=0
for i in range(Slen):
    for j in range(Slen-i-1):
        J=j+i+1
        karis=Slist[i:J+1]
        flag = 0
        for x in karis:
            if x == "A" or x == "T" or x == "C" or x == "G":
                pass
            else:
                flag = 1
                break
        if flag == 0:
            MAX=max(MAX,len(karis))
if MAX == 0:
    if "A" in S or "T" in S or "G" in S or "C" in S:
        print(1)
    else:
        print(0)
else:
    print(MAX)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int dp[N];
int go(int s)
{
	if(s==0)
	{
		return 1;
	}
	int &ans=dp[s];
	if(ans!=-1)
		return ans;
	ans=0;
	for(int i=3;i<=s;i++)
	{
		ans+=go(s-i);
		ans%=MOD;
	}
	return ans;
}
int32_t main()
{
	IOS;
	int n;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	cout<<go(n)<<endl;
}

Measured memory_bytes: 5992
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n-h+1)*(n-w+1) << endl;
	return 0;
}

Measured memory_bytes: 256