akhauriyash/Code-Regression huggingface dataset:
N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7
count1=0
for i in range(N-1):
    for m in range(i+1,N):
        count1+=A[i]>A[m]



count2=0
for i in range(N-1):
    for m in range(i+1,N):
        count2+=A[i]<A[m]

#print(count1,count2)
count=count1*((K*(K+1)//2)%mod)
count%=mod
count+=count2*(((K-1)*K//2)%mod)
count%=mod


print(count)


Measured memory_bytes: 41564
N = int(input())
A_list = list(map(int, input().split()))

temp_dict = {}
for i in A_list:
    if i not in temp_dict:
        temp_dict[i] = 1
    else:
        temp_dict[i] += 1

for i in range(1, N+1):
    if i in temp_dict:
        print(temp_dict[i])
    else:
        print(0)

Measured memory_bytes: 33636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	vector<int> p(A), q(B), r(C);
	REP(i, A) scanf("%d", &p[i]);
	REP(i, B) scanf("%d", &q[i]);
	REP(i, C) scanf("%d", &r[i]);
	
	sort(ALL(p), greater<int>());
	sort(ALL(q), greater<int>());
	sort(ALL(r), greater<int>());
	
	vector<pii> v;
	REP(i, B) v.emplace_back(q[i], 0);
	REP(i, C) v.emplace_back(r[i], 1);
	sort(ALL(v), greater<pii>());
	
	vector<pii> sum(v.size() + 1, pii(0, 0));
	REP(i, v.size()) {
		sum[i + 1] = sum[i];
		if (v[i].se == 0) ++sum[i + 1].fi;
		else ++sum[i + 1].se;
	}
	vector<ll> sumq(B + 1, 0), sumr(C + 1, 0);
	REP(i, B) sumq[i + 1] = sumq[i] + q[i];
	REP(i, C) sumr[i + 1] = sumr[i] + r[i];
	
	ll ans = 0, curp = 0;
	REP(i, X + 1) {
		ll cur;
		// X + Y - i 個選ぶ
		int scnum = min(X + Y - i, B + C);
		pii sc = sum[scnum];
		if (sc.fi > Y) {
			cur = curp + sumq[Y] + sumr[min(scnum - Y, C)];
		}
		else {
			cur = curp + sumq[sc.fi] + sumr[sc.se];
		}
		
		chmax(ans, cur);
		curp += p[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 6128
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};


int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll n;
    ll a,b;
    ll k,t;
    string str;
    ll h,w;
    cin>>h>>w;
    string s[h];
    rep(i,h){
        cin>>s[i];
    }
    map<char,ll> mp;
    set<char> se;
    ll f=0;
    ll sum=0;
    rep(i,h)rep(j,w) mp[s[i][j]]++;
    rep(i,h)rep(j,w) se.insert(s[i][j]);
    if(w%2&&h%2){
        ll okf=0;
        ll odds=0;
        if(h!=1&&w!=1){
            for(auto itr=se.begin();itr!=se.end();++itr){
                if(mp[*itr]%2)sum++;
                if(mp[*itr]%2==0&&mp[*itr]%4==2) odds++;
                if(mp[*itr]>=4) okf=1;
            }
        }else if(w==1&&h==1) okf=1;
        else{
            for(auto itr=se.begin();itr!=se.end();++itr){
                if(mp[*itr]%2)sum++;
                if(mp[*itr]>=2) okf=1;
            }
        }
        if(sum>1||okf==0||odds>h/2+w/2) f=1;
    }else if(w%2==0&&h%2==0){
        ll okf=0;
        for(auto itr=se.begin();itr!=se.end();++itr){
            if(mp[*itr]%4)f=1;
        }
       // f=1;
    }else{
        ll okf=0;
        ll odds=0;
        if(h!=1&&w!=1){
            for(auto itr=se.begin();itr!=se.end();++itr){
                if(mp[*itr]%2)sum++;
                if(mp[*itr]%2==0&&mp[*itr]%4==2) odds++;
                if(mp[*itr]>=4) okf=1;
            }
        }else if(w==1&&h==1) okf=1;
        else{
            for(auto itr=se.begin();itr!=se.end();++itr){
                if(mp[*itr]%2)sum++;
                if(mp[*itr]>=2) okf=1;
            }
        }
        if(h%2){
        if(sum>1||okf==0||odds>w/2) f=1;
        }else{
        if(sum>1||okf==0||odds>h/2) f=1;
        }
    }

    if(f) No;
    else Yes;

    return 0;
}


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

using namespace std;

typedef long long int ll;

void solve()
{
	int n;
	cin >> n;
	int x = 1000000;
	for(int i = 1; i <= x; i++)
	{
		if((i * n) % 360 == 0)
		{
			cout << i << "\n";
			return;
		}
	}
}

int main()
{
	int t = 1;
//	cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}



Measured memory_bytes: 3616
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextInt();
            }

            int gcd = A[0];
            for (int i = 1; i < A.length; i++) {
                gcd = gcd(gcd, A[i]);
            }
            System.out.println(gcd);
        }
    }

    public static final int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }
}


Measured memory_bytes: 50312
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int mergecount(vector<int> &a) {
  int count = 0;
  int n = a.size();
  if (n > 1) {
    vector<int> b(a.begin(), a.begin() + n/2);
    vector<int> c(a.begin() + n/2, a.end());
    count += mergecount(b);
    count += mergecount(c);
    for (int i = 0, j = 0, k = 0; i < n; ++i)
      if (k == c.size())       a[i] = b[j++];
      else if (j == b.size())  a[i] = c[k++];
      else if (b[j] <= c[k])   a[i] = b[j++];
      else                   { a[i] = c[k++]; count += n/2 - j; }
  }
  return count;
}
int main(){
	int n;
	while(cin>>n,n){
		vi a(n);
		rep(i,n)cin>>a[i];
		cout<<mergecount(a)<<endl;
	}
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+7;
ll l[N], r[N];
int main()
{
    ll ans = 1e18;
    int n, k, s1 = 0, s2 = 0;
    scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; i++)
    {
        int a;
        scanf("%d", &a);
        if(a<0)
        {
            l[++s1] = -a;
        }
        else if(a>0)
        {
            r[++s2] = a;
        }
        else
        {
            --k;
        }
    }
    sort(l+1, l+1+s1);
    for(int i = 0; i <= min(s1, k); i++)
    {
        if(s2+i>=k)
        {
            if(i==0)
            {
                ans = min(ans, r[k]);
            }
            else if(i==k)
            {
                ans = min(ans, l[k]);
            }
            else
            {
                ans = min(ans, min(l[i], r[k-i])+l[i]+r[k-i]);
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
int x[100], y[100];

ll calc(ll a, ll b) {
	return a * a + b * b;
}

int main() {
	cin >> N;
	REP(i, N) scanf("%d %d", x + i, y + i);
	
	ll ans = 0;
	REP(t, 112345) {
		double angle = t * 2*M_PI/112345.0;
		double X = cos(angle), Y = sin(angle);
		int curx = 0, cury = 0;
		REP(i, N) {
			if (X * x[i] + Y * y[i] >= EPS) {
				curx += x[i];
				cury += y[i];
			}
			chmax(ans, calc(curx, cury));
		}
	}
	printf("%.15lf\n", sqrt(ans));
	
	
	return 0;
}


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

#define int long long

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

signed main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D);
    return 0;
}

Measured memory_bytes: 764
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n;
vi a;

int main()
{
    cin >> n;
    a.resize(n+2);
    a[0] = 0; a[n + 1] = 0;
    rrep(i, n) cin >> a[i];

    ll base = 0;
    rep(i, n + 1){
        base += abs(a[i] - a[i + 1]);
    }

    for(int skip = 1; skip <= n; skip++){
        int mae = skip - 1, ato = skip + 1;
        ll ans = base - (abs(a[skip] - a[mae]) + abs(a[ato] - a[skip])) + abs(a[ato] - a[mae]);
        cout << ans << endl;
    }

}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define PI 3.14159265
#define ll long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 300000000000000001
#define infx 9223372036854775806
#define all(c) c.begin(),c.end()
#define mk(x,yy) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
#define re return
// #define endl "\n"
#define max2(x,y)           (x>y)?x:y
#define min2(x,y)           (x<y)?x:y
#define mid(s,e)               (s+(e-s)/2)
#define mini                   INT_MIN
#define maxo                   INT_MAX
#define rep(i,a,b) for(int i=a;i<(int)(b);++i)
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define show(a,n) for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl
#define ene cout<<"\n";

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
ll power(ll x,  ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
 
bool compr(std::vector<ll> a, std::vector<ll> b)
{
    if(a[0]==b[0])
        return a[1]<b[1];
    else
        return a[0]<b[0];
}

bool comp(std::vector<ll> a, std::vector<ll> b)
{
    if(a[1]==b[1]&&a[2]==b[2])
        return a[0]<b[0];
    else if(a[1]==b[1])
        return a[2]>b[2];
    else
        return a[1]<b[1];
}

int main()
{
    #ifdef SHIVANSH 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    char a[n][m];
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
            cin>>a[i][j];
    }
    ll dp[n][m];
    if(a[0][0]=='.')
        dp[0][0] = 1;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            if(i==0&&j==0)
                continue;
            else
            {
                if(a[i][j]=='#')
                    dp[i][j] = 0;
                else
                {
                    if(i==0)
                        dp[i][j] = dp[i][j-1];
                    else if(j==0)
                        dp[i][j] = dp[i-1][j];
                    else
                        dp[i][j] = (dp[i][j-1] + dp[i-1][j])%mod;
                }
            }
        }
    }
    cout<<dp[n-1][m-1]<<endl;
}

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

namespace id_0238cs
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var t = int.Parse(Console.ReadLine());
                if (t == 0) break;
                var n = int.Parse(Console.ReadLine());
                int sum = 0;
                foreach (var s in Enumerable.Range(0, n))
                {
                    var vs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                    sum += vs[1] - vs[0];
                }
                if (sum < t)
                {
                    Console.WriteLine(t - sum);
                }
                else
                {
                    Console.WriteLine("OK");
                }
            }
        }
    }
}



Measured memory_bytes: 9716
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N, K;
  ll ans = LLONG_MAX;
  
  cin >> N >> K;
  vector<ll> x(N), y(N);
  for(int i = 0; i < N; i++){
    cin >> x[i] >> y[i];
  }

  for(int x1 = 0; x1 < N; x1++){
    for(int y1 = 0; y1 < N; y1++){
      for(int x2 = 0; x2 < N; x2++){
	for(int y2 = 0; y2 < N; y2++){
	  int cnt = 0;
	  for(int i = 0; i < N; i++){
	    if(x[x1] <= x[i] && x[i] <= x[x2] && y[y1] <= y[i] && y[i] <= y[y2]){
	      cnt++;
	    }
	  }
	  if(K <= cnt) ans = min(ans, (x[x2] - x[x1]) * (y[y2] - y[y1]));
	}
      }   
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.Arrays

const val MOD: Long = (1e9+7).toLong()

fun main(args: Array<String>) {
    val s = readLine()!!

    val sb = StringBuilder("")
    var b = s[0]
    for (c in s) {
        if (c == b) {
            continue
        } else {
            sb.append(b)
            b = c
        }
    }
    sb.append(b)

    println(sb.length-1)
}


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

int main(int argc, char const *argv[])
{
  int N,A,b=0,ans=0; // b : ビット和
  cin >> N;

  for (int i = 0; i < N; ++i)
  {
    cin >> A; // A[i]を格納
    b = (A | b); // bはA_1～A_Nのビット和
  }

  while((b&1)==0){ // ビット和の最下位ビットが0である限り
    b = b>>1; // ビット和を右に1ビットシフトして
    ans++; // 操作回数を1回増やす
  }

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

Measured memory_bytes: 3624
#include<iostream>
#include <algorithm>
using namespace std;
int N_MAX = 1000000;
typedef pair<int,int> P;
int main()
{
  int a[N_MAX+1];
  int s;
  cin >> s;
  int aa=s;
  int i=1;
  while(true){
    if(a[aa]>0){
	  cout << i << endl;
  	  return 0;
    } else {
      a[aa]=i;
      i++;
      if(aa%2==0) aa/=2;
      else aa=aa*3+1;
    }
  }
}

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

int main(){
    int n;cin>>n;
    int M=0,s=0,l;
    for(int i=0;i<n;i++){
        cin>>l;
        M=max(M,l);
        s+=l;
    }
    if(M<s-M) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;

// #define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

int N, M, C;
vector<vector<int>> G;
vector<int> con, used;

void solve(int node = 1, int per = -1){
	if(used[node]) return ;
	used[node] = ++C;
	
	for(int y : G[node]){
		if(y == per) continue;
		if(used[y]){
			if(used[node] > used[y]){
				con[node]++;
				cout<<node<<" "<<y<<endl;
			}
		} else {
			solve(y , node);
		}
	}
	
	if(per == -1) return;
	
	if(con[node]%2){
		cout<<node<<" "<<per<<endl;
		con[node]++;
	} else {
		cout<<per<<" "<<node<<endl;
		con[per]++;
	}
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
	int a, b;

	cin>>N>>M;
	
	G.resize(N+10);
	con.resize(N+10);
	used.resize(N+10);
	
	for(int i = 0; i < M; i++){
		cin>>a>>b;
		
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	if(M%2){
		cout<<-1<<endl;
		return 0;
	}
	
	solve();
	
	
	return 0;
}

Measured memory_bytes: 15488
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

const int N = 70;

char input[N][N];
string myMax(string a, string b){
  if(a.length() != b.length()){
    if(a.length() > b.length()) return a;
    else return b;
  }
  return max(a,b);
}

string solve(int h, int w){
  string dp[h][w];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(isalpha(input[i][j]) || input[i][j] == '0'){
	dp[i][j] = "";
      }else{
	dp[i][j] = input[i][j];
      }
    }
  }

  string result = "0";
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(isalpha(input[i][j])) continue;

      if(i > 0 && dp[i-1][j] != ""){
	dp[i][j] = myMax(dp[i][j],dp[i-1][j]+input[i][j]);
      }
      if(j > 0 && dp[i][j-1] != ""){
	dp[i][j] = myMax(dp[i][j],dp[i][j-1]+input[i][j]);
      }

      result = myMax(result,dp[i][j]);
    }
  }
  return result;
}

int main(){
  int h,w;
  while(cin >> w >> h){
    if(w == 0 && h == 0) break;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	cin >> input[i][j];
      }
    }
    cout << solve(h,w) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
n = gets.to_i
robots = n.times.map{gets.split.map(&:to_i)}

robots.sort! { |a, b| a[0] + a[1] <=> b[0] + b[1] }

max_left = -10**9
ans = 0
robots.each do |x, l|
  if max_left <= x - l
    ans += 1
    max_left = x + l
  end
end

puts ans


Measured memory_bytes: 12536
a, b, t = open(0)
n, k = map(int, a.split())
r, s, p = map(int, b.split())
d = {"r": ("p", p), "s": ("r", r), "p": ("s", s)}
command = [0]*n
point = 0
for i, s in enumerate(list(t.strip())):
  c, q = d[s]
  if i-k >= 0 and command[i-k] == c:
    continue
  command[i] = c
  point += q
print(point)

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

int main()
{
    vector<int> x(3, 0);
    cin >> x[0] >> x[1] >> x[2];
    sort(x.begin(), x.end());
    if (x[0] == 5 && x[1] == 5 && x[2] == 7)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

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

using namespace std;

#define fileInput(problemName) freopen ((string(problemName) + ".inp").c_str(), "r", stdin);freopen ((string(problemName) + ".out").c_str(), "w", stdout);
#define ll long long

const ll inf = 1e9 + 7;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 7;

int n, k, a[N], f[N];

main() {
    //fileInput("frog-2");
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) f[i] = inf;
    f[1] = 0;
    f[2] = abs(a[2] - a[1]);
    for (int i = 3; i <= n; i++) {
        for (int j = i - 1, counter = 0; j >= 1 and counter < k; j--, counter++) {
            f[i] = min(f[i], f[j] + abs(a[i] - a[j]));
        }
    }
    // for (int i = 1; i <= n; i++) cout << f[i] << " ";
    // cout << endl;
    cout << f[n] << endl;
}

Measured memory_bytes: 4416
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        String N = scanner.next();
        int K = Integer.parseInt(scanner.next());

        int[][][] dp = new int[N.length() + 1][K + 2][2];
        // 0 digit, 0 non-0, same
        dp[0][0][0] = 1;

        for (int i = 0; i < N.length(); i++) {
            int c = N.charAt(i) - '0';
            for (int j = 0; j <= K; j++) {
                if (c == 0) {
                    dp[i + 1][j][0] += dp[i][j][0];
                } else {
                    dp[i + 1][j + 1][0] += dp[i][j][0];
                    dp[i + 1][j + 1][1] += (c - 1) * dp[i][j][0];
                    dp[i + 1][j][1] += dp[i][j][0];
                }
                dp[i + 1][j][1] += dp[i][j][1];
                dp[i + 1][j + 1][1] += 9 * dp[i][j][1];
            }
        }

        System.out.println(dp[N.length()][K][0] + dp[N.length()][K][1]);

    }
}



Measured memory_bytes: 24020
import numpy as np
s = np.array(list(input()))
t = np.array(list(input()))
n = len(s)
m = len(t)
match = s.reshape(-1,1) == t.reshape(1,-1)
lcs = np.zeros((n+1, m+1), dtype='int32')
for i in range(n):
    lcs[i+1,1:] = np.fmax(lcs[i,:-1]+match[i],lcs[i,1:])
    lcs[i+1] = np.maximum.accumulate(lcs[i+1])
l = []
while n > 0 and m > 0:
    if lcs[n, m] == lcs[n-1, m]:
        n-=1
    elif lcs[n, m] == lcs[n, m-1]:
        m-=1
    else:
        l.append(s[n-1])
        n-=1
        m-=1
print(''.join(l[::-1]))


Measured memory_bytes: 56696
#include <stdio.h>

int main() {
    int i, k, v,an1,an2,suu;
    int MAX_V = 1000000;
    int prime[MAX_V+1];
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1;
    }
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0;   
            } 
        }
    }
    while(1){
        scanf("%d",&suu);
        if(suu == 0)  break;
        for(k=2;k<=suu;k++){
            if(prime[k-2]==1 && prime[k]==1){
        	    an1=k-2;
        	    an2=k;
            }
        }
        printf("%d %d\n",an1,an2);
    }
    return 0; 
}

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

#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end()); 
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));

//ffs = lsb, clz = l0's, ctz = r0's, popcount = 1's 
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
    fastio();
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i  < s.size(); ++i){
        if(s[i] == '-'){
            ans -= 1;
        }else{
            ans += 1;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int H, W;
int N;
int a[10101];
int ans[110][110];

int main() {
  cin >> H >> W;
  cin >> N;
  rep(i, 0, N) { cin >> a[i]; }

  int cnt = 0;
  for (int i = 0; i < H; ++i) {
    if (i % 2 == 0) {
      for (int j = 0; j < W; ++j) {
        if (a[cnt] == 0) {
          ++cnt;
        }
        --a[cnt];

        ans[i][j] = cnt + 1;
      }
    } else {
      for (int j = W - 1; j >= 0; --j) {
        if (a[cnt] == 0) {
          ++cnt;
        }
        --a[cnt];

        ans[i][j] = cnt + 1;
      }
    }
  }

  rep(i, 0, H) {
    rep(j, 0, W) { cout << ans[i][j] << " "; }
    cout << "\n";
  }
}


Measured memory_bytes: 3684
import math
def difference(li):
  x=[int(i) for i in range(1,n+1)]
  l=len(li)
  sum=0
  for i in range(l):
    sum+=math.factorial(l-i-1)*(x.index(li[i]))
    x.remove(li[i])  
  return sum+1

n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r1=difference(p)
r2=difference(q)
result=abs(r1-r2)
print(result)

Measured memory_bytes: 38384
package main

import "fmt"

func main() {
	var n, a int
	fmt.Scan(&n)
	var m [2]int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		m[a%2]++
	}
	// fmt.Println(m)
	m[0] += m[1] / 2
	m[1] = m[1] % 2
	// fmt.Println(m)
	for m[0] > 1 {
		m[0] = m[0]/2 + m[0]%2
	}
	// fmt.Println(m)
	if (m[0]+m[1])%2 == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 5504
import java.util.*;

public class Main {

	char[][] board;
	int W, H;

	void run(){
		Scanner in = new Scanner(System.in);
		for(;;){
			H = in.nextInt();
			W = in.nextInt();
			if(H==0 && W==0) return ;
			board = new char[H][];
			for(int i=0; i<H; i++){
				board[i] = in.next().toCharArray();
			}
			System.out.println(solve());
		}
	}

	int solve(){
		int[][] accum = new int[H][W+1];
		int ans = 0;
		for(int i=0; i<H; i++){
			for(int j=0; j<W; j++){
				accum[i][j+1] = accum[i][j] + (board[i][j]=='*'?1:0);
			}
		}
		for(int j=0; j<W; j++)for(int k=j+1; k<=W; k++){
			int len = 0, cur=0;
			for(int i=0; i<H; i++){
				if(accum[i][k] - accum[i][j] == 0){
					cur++;
				}
				else{
					cur = 0;
				}
				if(len < cur){
					len = cur;
				}
			}
			ans = Math.max(ans, (k-j)*len);
		}
		return ans;
	}

	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 14000
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define bg begin()
#define end end()
#define sz size()
#define vi vector<int>
#define vl vector<long long int>
int main(){
	fast;
	ll n;
	cin>>n;
	ll arr[n]={0};
	for(int i=1;i<100;i++)
		for(int j=1;j<100;j++)
			for(int k=1;k<100;k++)
			{
				if(i*i + j*j + k*k +i*j +j*k +i*k <=n )
					arr[i*i + j*j + k*k+i*j +j*k +i*k - 1]++;
				else
					break;
			}
	for(int i=0;i<n;i++)
		cout<<arr[i]<<endl;
	return 0;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int k= 1;
        HashMap<String,Integer> hashMap = new HashMap<>();
        hashMap.put("SUN",7);
        hashMap.put("MON",6);
        hashMap.put("TUE",5);
        hashMap.put("WED",4);
        hashMap.put("THU",3);
        hashMap.put("FRI",2);
        hashMap.put("SAT",1);
        String s1;
        String s2;
        int a,b;
        double n;
        while(k-->0){
            n=s.nextDouble();
            if(n%2==0)
                System.out.println((n/2)/n);
            else
                System.out.println((n+1)/(2*n));
        }
    }

    private static int binary_search(
            int arr[], int l,
            int h, int x)
    {
        while (l <= h) {
            int mid = (l + h) / 2;
            if (arr[mid] <= x)
                l = mid + 1;
            else
                h = mid - 1;
        }
        return h;
    }
    static int gcd(int a, int b)
    {
        if(b==0) {
            return a;
        }
        return gcd(b,a%b);
    }
    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

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

using LL = long long;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

    int n; cin >> n;
    string s; cin >> s;
    for (char& ch: s) {
        ch = (ch - 'A' + n) % 26 + 'A';
    }
    cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <cmath>
#include <string.h>
#include <stdio.h>

using namespace std;

int main(){

  string S;
  
  cin >> S;
  
  int cnt =0;
  int answer = 0;
  for(int i=0; i<S.size(); i++){
    if(S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'T' || S.at(i) == 'G'){
      cnt++;
      answer = max(cnt, answer);
    }
    else{
      cnt = 0;
    }
  }
  
  cout << answer << endl;
  

  
  return 0;
  
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N;
  cin >> N;
  auto xyh = mvec<ll>(0,3);
  ll hmin{MOD};
  rep(i,0,N){
    ll x, y, h;
    cin >> x >> y >> h;
    hmin = min(hmin, h);
    xyh.push_back({x, y, h});
  }
  rep(x, 0, 101) rep(y, 0, 101) rep(h, hmin, hmin+201){
    bool isanswer{true};
    for(auto&& i : xyh){
      if(max(h - abs(x-i[0]) - abs(y-i[1]), 0LL) != i[2]) isanswer = false;
    }
    if(isanswer){
      cout << x << sp << y << sp << h << rt;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
#define INF 10e6
#define MAX_V 30001
//辺を表す構造体
struct edge{int to;int cap;int rev;};

vector<edge>G[MAX_V];//グラフの隣接リスト表現
int level[MAX_V];//sからの距離
int iter[MAX_V];//どこまで調べ終わったか

//fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(int from,int to,int cap){
   G[from].push_back((edge){to,cap,G[to].size()});
   G[to].push_back((edge){from,/*0*/cap,G[from].size()-1});
}

//sからの最短距離をBFSで計算する
void bfs(int s){
   memset(level,-1,sizeof(level));
   queue<int> que;
   level[s]=0;
   que.push(s);
   while(!que.empty()){
         int v=que.front();que.pop();
         REP(i,G[v].size()){
             edge& e=G[v][i];
             if(e.cap>0&&level[e.to]<0){
                level[e.to]=level[v]+1;
                que.push(e.to);
             }
         }
   }
}

//増加パスをdfsで探す
int dfs(int v,int t,int f){
    if(v==t){
       return f;
    }
    for(int &i=iter[v];i<G[v].size();i++){
        edge& e=G[v][i];
        if(e.cap>0&&level[v]<level[e.to]){
           int d =dfs(e.to,t,min(f,e.cap));
           if(d>0){
              e.cap -=d;
              G[e.to][e.rev].cap+=d;
              return d;
           }
        }
    }
    return 0;
}

//sからtへの最大流を求める
int max_flow(int s,int t){
   int flow=0;
   for(;;){
       bfs(s);
       if(level[t]<0)return flow;
       memset(iter,0,sizeof(iter));
       int f;
       while((f=dfs(s,t,INF))>0){
          flow +=f;
       }
   }
}
int H,W;
int a[101][101];
int S;
int T;

int main(){
//ここで辺を加える
    cin>>H>>W;
    REP(i,H){
        string s;
        cin>>s;
        REP(j,W){
            a[i][j]=0;
            if(s[j]=='S'){
               a[i][j]=1;
               add_edge(i*W+j,10010+j,INF/10);
               add_edge(i*W+j,10010+W+i,INF/10);
               S=i*W+j;
            }
            if(s[j]=='T'){
               a[i][j]=1;
               T=i*W+j;
               add_edge(i*W+j,10010+j,INF/10);
               add_edge(i*W+j,10010+W+i,INF/10);
            }
            if(s[j]=='o'){
               a[i][j]=1;
               add_edge(i*W+j,10010+j,1);
               add_edge(i*W+j,10010+W+i,1);
            }
        }
    }

    //ここで最大流の計算をする
    int ans=max_flow(S,T);
    if(ans>=INF/10){
       cout<<-1<<endl;
    }else{
       cout<<ans<<endl;
    }

}

Measured memory_bytes: 1920
H = int(input())

# INF = float('inf')

# dp = [INF for i in range(H+10)]
# dp[0] = 0
# dp[1] = 1

# for i in range(1, H+1):

#     dp[i+1] = min(dp[i+1], dp[(i+1)//2] * 2 + 1)

# print(dp[H])

cnt = 0
while H > 1:
    cnt += 1
    H //= 2
    
ans = 0
for i in range(cnt):
    ans += 2**i
ans += 2**cnt
print(ans)

Measured memory_bytes: 38256
#include<stdio.h>
int main(void){
    int NumberOfGoods,sum,price,max;
    scanf("%d", &NumberOfGoods);
    sum = 0;
    max = 0;
    for (int i=1;i<=NumberOfGoods;i++){
        scanf("%d",&price);
        sum += price;
        if (price >= max)max = price;
    }
    printf("%d", sum-max/2);
    return 0;
}

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

int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if((a>=1 && a<=100) && (b>=1 && b<=100) && (c>=1 && c<=100))
    {
        if(b < a)
            printf("0\n");
        else if(b/a > c)
            printf("%d\n", c);
        else
            printf("%d\n", b/a);
    }

}


Measured memory_bytes: 256
import sys

def debug(*args):
    print(*args, file=sys.stderr)


def solve(A, B):
    if A > B:
        A, B = B, A
    if (B - A) % 2 == 1:
        return "IMPOSSIBLE"
    return A + ((B-A)//2)

def main():
    A, B = [int(x) for x in input().split()]
    print(solve(A, B))

main()


Measured memory_bytes: 2940
X, K, D = list(map(int, input().split()))

X = abs(X)

minNeedCount = X // D
rightRest = X % D
leftRest = abs(rightRest - D)

if K < minNeedCount:
  res = X - K*D
else:
  if (K-minNeedCount) % 2 == 0:
    res = rightRest
  else:
    res = leftRest

print(res)

Measured memory_bytes: 61652
A=[int(x) for x in input()]
n=len(A)-1
P=[]
for i in range(2**n):
    L=['']*n
    for j in range(n):
        if (i>>j)&1:
            L[j]='+'
    formula=''
    for a,b in zip(A,L+['']):
        formula+=(str(a)+b)
    P.append(eval(formula))
print(sum(P))

Measured memory_bytes: 3064
l = []
l.append(int(input()))
i = 0
key = 1
while key:
  if l[i]%2:
    l.append(3*l[i]+1)
  else:
    l.append(l[i]/2)
  i += 1
  for j in range(i-1):
    if l[j] == l[i]:
      key = 0
      print(i+1)
      break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
//#define MOD 1000000007
const int INF = 1LL<<30;

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

    vector<pair<int,int>> res;
    int dame=n;
    if(n%2==1) dame--;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(j<=i || j==dame) continue;
            res.push_back({i,j});
        }
        dame--;
    }

    cout<<res.size()<<endl;
    for(auto p : res) cout<<p.first<<" "<<p.second<<endl;
}

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

public class Main{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
        public FastReader(String fileName) throws FileNotFoundException{br = new BufferedReader(new FileReader(fileName));}
        String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt(){return Integer.parseInt(next());}
        long nextLong(){return Long.parseLong(next());}
        double nextDouble(){return Double.parseDouble(next());}
        char[][] readCharArray(int n,int m) {
        	String str;
        	char[][] arr = new char[n][m];
        	for(int i=0;i<n;i++) {
        		str=nextLine();
        		for(int j=0;j<n;j++) {
        			arr[i][j]=str.charAt(j);
        		}
        	}
        	return arr;
        }
        char[][] readCharArray(int n){
        	return readCharArray(n,n);
        }
        int[] readArray(int n){int[] a=new int[n];for (int i=0; i<n; i++) a[i]=nextInt();return a;}
        long[] readLongArray(int n){long[] a=new long[n];for (int i=0; i<n; i++) a[i]=nextLong();return a;}
        String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}
    }
    static final Random random=new Random();
    static void ruffleSort(int[] a) {
        int n=a.length;//shuffle, then sort
        for (int i=0; i<n; i++) {
            int oi=random.nextInt(n), temp=a[oi];
            a[oi]=a[i]; a[i]=temp;
        }
        Arrays.sort(a);
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
    	FastReader st = new FastReader();
    	System.out.println(st.nextInt()==0?1:0);
    }
}

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

int gcd(int x, int y){
    int result = 0;
    int tmp;
    int r;
    if(x < y){
        tmp = x;
        x = y;
        y = tmp;
    }
    r = x % y;
    while(r != 0){
        x = y;
        y = r;
        r = x % y;
    }
    //cout << y << endl;
    return y;
}

int main(){
    long long int n;
    cin >> n;
    long long int sum = 0;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                sum += gcd(gcd(i, j), k);
            }
        }
    }
    cout << sum << endl;
}

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

namespace abc126A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string b = Console.ReadLine();
            string bK = b[a[1] - 1].ToString();
            if (bK == "A") { bK = "a"; }
            if (bK == "B") { bK = "b"; }
            if (bK == "C") { bK = "c"; }
            for(int i = 0; i < a[0]; i++)
            {
                if (i == a[1] - 1) { Console.Write(bK); }
                else Console.Write(b[i]);
            }

        }

    }
}


Measured memory_bytes: 28064
import Control.Monad
import Control.Applicative
mMulV m v = map calcEachLine m where
    calcEachLine l = sum $ zipWith (*) l v
main = do
    [n,m] <- map read . words <$> getLine
    matrix <- replicateM n $ map (read :: String->Int) . words <$> getLine :: IO [[Int]]
    vector <- replicateM m $ (read :: String->Int) <$> getLine :: IO [Int]
    mapM_ print $ mMulV matrix vector

Measured memory_bytes: 7564
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, k;
    cin >> n >> k;
    vint a(n);
    rep(i, n) cin >> a[i];
    sort(rall(a));
    set<int> diff;
    diff.insert(INF);
    rep(i, n-1) {
        if (a[i] != a[i+1]) diff.insert(a[i] - a[i+1]);
    }
    rep(i, n) {
        if (a[i] < k) {
            puts("IMPOSSIBLE");
            return 0;
        }
        if (a[i] == k) {
            puts("POSSIBLE");
            return 0;
        }
        for (int d : diff) {
            if ((a[i]-k) % d == 0) {
                puts("POSSIBLE");
                return 0;
            }
        }
    } 

    puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<string>;
using P =pair<int,int>;
const ll mod=1000000007;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int main(){
    ll n,k;
    cin>>n>>k;
    ll tmp=n/k;
    ll tmp1=pow(tmp,3);//tmp*tmp*tmp;
    if(k%2!=0){
        cout<<tmp1<<endl;
    }else{
        ll tmp3=pow((n+k/2)/k,3);//tmp2*tmp2*tmp2;
        cout<<tmp1+tmp3<<endl;
    }
}


Measured memory_bytes: 4004
using System;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int D = int.Parse(Console.ReadLine());

            if (D == 25) {
                Console.Write("Christmas");
            }
            if (D == 24)
            {
                Console.Write("Christmas Eve");
            }
            if (D == 23)
            {
                Console.Write("Christmas Eve Eve");
            }
            if (D == 22)
            {
                Console.Write("Christmas Eve Eve Eve");
            }


        }
    }
}


Measured memory_bytes: 11092
#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<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int main() {
    int n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;

    int ans = 0;
    REP(i,n){
        set<char> st;
        st.insert(a[i]);
        st.insert(b[i]);
        st.insert(c[i]);
        ans += st.size() - 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var N, K int
	var S string
	fmt.Scan(&N, &K, &S)
	strs := []string{S[:K-1], string(S[K-1] - 'A' + 'a'), S[K:]}
	fmt.Println(strings.Join(strs, ""))
}


Measured memory_bytes: 640