akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b,k;
    cin>>a>>b>>k;
    rep(i,k){
        if(i%2==0){
        if(a%2==1){
            a--;
        }
        a/=2;
        b+=a;
        }
        else{
        if(b%2==1){
            b--;
        }
        b/=2;
        a+=b;
        }
    }
    cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
using System;

namespace AtcoderCS
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            long total = 0;
            for(long i = 1; i <= N; i++)
            {
                long first = i;
                long count = N / i;
                long last = count * i;

                total += (first + last) * count / 2;
            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 27420
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var nrl=arr.shift().split(" ").map(Number);
var n=nrl[0];
var L=nrl[2];
var t=[];
var max=[0,0];
var time=0;
for(var i=0;i<n;i++)t[i]=[0,0,i];
arr.push([1,L,0].join(" "));
arr.forEach(function(v){
   v=v.split(" ").map(Number);
   var d=v[0]-1;
   var T=v[1];
   var x=v[2];
   t[max[0]][1]+=T-time;
   time=T;
   t[d][0]+=x;
   if(x>0){
      if(t[d][0]>max[1])max=[d,t[d][0]];
      else if(t[d][0]==max[1] && d<=max[0])max=[d,t[d][0]];
   }
   else if(x<0 && max[0]==d){
      var MAX=0;
      var m=0;
      t.forEach(function(V,index){
         if(MAX<V[0]){m=index;MAX=V[0];}
      });
      max=[m,t[m][0]];
   }
});
t.sort(function(a,b){
   if(a[1]==b[1])return a[2]-b[2];
   else return b[1]-a[1];
});
console.log(t[0][2]+1);

Measured memory_bytes: 127004
def main():
    INF = 2 ** 60
    n, k = map(int, input().split())
    hs = list(map(int, input().split()))

    dp = [INF for _ in range(n)]
    dp[0] = 0

    for i in range(n):
        for j in range(1, k + 1):
            if i + j >= n:
                break
            dp[i + j] = min(dp[i + j], dp[i] + abs(hs[i] - hs[i + j]))

    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 90044
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
using namespace std;
int prime[10001];
void make_prime(){
  fill(prime,prime+10001,1);
  prime[0] = 0;
  prime[1] = 0;
  for(int i = 2;i <= 10001;i++){
	if(!prime[i])continue;
	for(int j = i*2;j <= 10001;j+=i){
	  prime[j] = 0;
	}
  }
}
bool is_prime(int i){
  return prime[i];
}
int main(){
  int n;
  make_prime();
  while(cin >> n){
	
	int ans = 0;
	for(int i = 1;i <= n;i++){
	  if(is_prime(i) && is_prime(n-i+1))ans++;
	}
	cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

public interface Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = 1;
		while(sc.hasNext()) {
			int a = sc.nextInt();
			if(a==0) break;
			System.out.printf("Case %d: %d\n",n,a);
			n++;
		}
		
		
	}
}



Measured memory_bytes: 70368
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;
typedef pair<int,int> pii;

int main() {
    int N, H;
    cin >> N >> H;
    vector<pii> v;
    v.reserve(2 * N);
    REP (i, 0, N) {
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(a, 2));
        v.push_back(make_pair(b, 1));
    } 
    sort(v.rbegin(), v.rend());
    int res = 0;
    REP (i, 0, 2 * N) {
        if (H <= 0) break;
        if (v[i].second == 2) {
            res += (H + v[i].first - 1) / v[i].first;
            H = 0;
        } else {
            res++;
            H -= v[i].first;
        }
    }
    cout << res << endl;
    return 0;
}

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

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double h = 360 / 12 * H + 30.0 / 60 * M;
  double m = 360 / 60 * M;
  h *= M_PI / 180;
  m *= M_PI / 180;
  double ans = hypot(A * sin(h) - B * sin(m), A * cos(h) - B * cos(m));
  cout << fixed << setprecision(9) << ans << "\n";
}

Measured memory_bytes: 4132
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
const ll mod=1e+9+7;
int main(void){
    ll n;cin>>n;
    ll res=1;
    map<ll,ll> mp;
    for(ll i=2;i<=n;i++){
        ll now=i;
        for(ll j=2;j<=sqrt(now);j++){
            while(now%j==0){
                mp[j]++;
                now/=j;
            }
        }
        if(now>1)mp[now]++;
    }
    for(auto& p:mp){
        res*=(p.second+1);
        res%=mod;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
 
signed main(){
    string A,B;
    cin >>A>>B;
    int X=stoi(A+B);
    int d=sqrt(X);
  	d*d==X ? cout<<"Yes"<<endl:cout<<"No"<<endl;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> prefs(n);
  for (int i = 0; i < m; i++) {
    int p, y;
    cin >> p >> y;
    p--;
    prefs[p].push_back({y, i});
  }

  auto gen_id = [](int pref, int order) {
    stringstream ss;
    ss << setfill('0') << right << setw(6) << pref;
    ss << setfill('0') << right << setw(6) << order;
    return ss.str();
  };

  vector<pair<int, string>> ids;
  for (int i = 0; i < prefs.size(); i++) {
    sort(prefs[i].begin(), prefs[i].end());
    for (int j = 0; j < prefs[i].size(); j++) {
      ids.push_back({prefs[i][j].second, gen_id(i + 1, j + 1)});
    }
  }

  sort(ids.begin(), ids.end());
  for (int i = 0; i < ids.size(); i++) {
    cout << ids[i].second << '\n';
  }

  return 0;
}

Measured memory_bytes: 13168
#include<stdio.h>
int main (void){
    int N,n,h,t,g;
    scanf("%d",&N);
    h=N/100;
    t=(N%100)/10;
    g=N%10;
    if(h>t){
        n=100*h+10*h+h;
        printf("%d\n",n);
    }
    else if(h<t){
        n=100*(h+1)+10*(h+1)+(h+1);
        printf("%d\n",n);
    }
    else{
        if(g<=t){
            n=100*t+10*t+t;
            printf("%d\n",n);
        }else{
            n=100*(t+1)+10*(t+1)+(t+1);
            printf("%d\n",n);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = acos(-1.0);

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

int main() {
    int H, W, h, w; cin >> H >> W >> h >> w;

    cout << H * W - (h * W + H * w - h * w) << endl;
    return 0;
}


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

	ll n;
	cin >> n;

	ll a[n][n];
	rep(i,n) rep(j,n) cin >> a[i][j];


	// Warshall-Floyd

	// すべての2頂点間に辺を張ったグラフを考え、各距離がa[i][j]であるとする
	// 最短距離の更新があれば、そのようなグラフは存在しない(最短距離の情報が矛盾している)	
    // a[i][j] == a[i][k] + a[k][j]　であれば、辺ijは不要

	bool b[n][n] = {};

	ll sum = 0;
	FOR(i,0,n){
		FOR(j,i+1,n){
			sum += a[i][j];
		}
	}

	ll ans = 0;

	rep(k,n){
		rep(i,n){
			rep(j,n){
				if(k != i && i != j && j!= k) {
					if(a[i][j] > a[i][k] + a[k][j]){
						cout << -1 << endl;
						return 0;
					}else{
						if((a[i][j] == a[i][k] + a[k][j]) && (!b[i][j] || !b[j][i])){
							ans += a[i][j];
							b[i][j] = true;
							b[j][i] = true;
						}
					}
				}
			}
		}
	}
	
	cout << (sum - ans) << endl;
}

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

int main()
{
    string s;
    cin>>s;
    string s3=s;
    int n1,n2;
    n1=(s.size()-1)/2;
    n2=(s.size()+3)/2-1;
    string s1=s.substr(0,n1);
    string s2=s.substr(n2,s.size());
    string s11,s22;
    s11=s1; s22=s2;
    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());
    reverse(s3.begin(),s3.end());
    if(s1==s11 && s2==s22 && s==s3)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}

void solution() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double ang1 = h * 360 / 12;
  double x = ((double)m / 60) * 360 / 12;
  ang1 += x;
  // cout << ang1 << endl;
  double ang2 = m * 360 / 60;
  double ang = abs(ang1 - ang2);
  ang = min(ang, 360 - ang);
  double ans = a * a + b * b - 2 * a * b * cos((double)(ang * PI) / 180);
  cout << fixed << setprecision(15) << sqrt(ans) << endl;
}

int32_t main() {
  DESYNC;
  solution();
}


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

int main() {
    int A, B, C, D;

    cin >> A >> B >> C >> D;

    if ((A + B) > (C + D)) {
        cout << "Left" << endl;
    } else if ((A + B) == (C + D)) {
        cout << "Balanced" << endl;
    } else {
        cout << "Right" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, K; 
  cin >> N >> K;

  vector<int> h(100010);
  for(int i=0; i<N; i++) cin >> h[i];

  int cnt = 0;
  for (int i=0; i<N; i++){
    if(h[i] >= K) cnt++;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }
int main() {
    int n; cin>>n;
    vl a(n+1);
    rep(i,n){
        cin>>a[i+1];
        a[i+1]+=a[i];
    }

    map<ll,ll> nums; rep(i,n+1) nums[a[i]]++;

    ll res=0;
    for (auto it : nums) {
        ll num = it.second; // it.first が it.second 個ある
        res += num * (num - 1) / 2;
    }
    cout << res << endl;
}

Measured memory_bytes: 14336
#include "bits/stdc++.h"
using namespace std;
int a[10][10],b[10][10],ans[10][10];
int dx[]={1,0,-1,0,0},dy[]={0,1,0,-1,0};

void init(void){for(int i=0;i<10;i++){for(int j=0;j<10;j++){b[i][j]=a[i][j];ans[i][j]=0;}}}

void rev(int x, int y){for(int k=0;k<5;k++){int ny=y+dy[k],nx=x+dx[k];
    if( 0<=ny && 0<=nx && ny<10 && nx<10)b[ny][nx]=!b[ny][nx];}}

int ok(void){for(int i=0;i<10;i++)for(int j=0;j<10;j++)if(b[i][j])return 0;return 1;}

void solve(int p[]){
  init();for(int i=0;i<10;i++){if(p[i])rev(i,0);ans[0][i]=p[i];}
  for(int i=1;i<10;i++){for(int j=0;j<10;j++){if(b[i-1][j]){rev(j,i);ans[i][j]=1;}}}
  if(ok()){for(int i=0;i<10;i++){for(int j=0;j<10;j++){	cout << ans[i][j];if(j<9)cout << " ";}cout << endl;}}}

void func(int p[], int cnt){if(9<cnt)solve(p);else {p[cnt]=0;func(p,cnt+1);p[cnt]=1;func(p,cnt+1);}}

int main(void){
  int n;cin >> n;
  while(n--){for(int i=0;i<10;i++)for(int j=0;j<10;j++)cin >> a[i][j];
    int p[10]={0};func(p,0);
  }return 0;}

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

typedef long long ll;

int main () {
    string l;
    cin >> l;
    for (int i = 0; i < l.size(); i++) {
        for (int j = 0; j < l.size(); j++) {
            if (i == j);
            else {
                if (l[i] == l[j]) {
                    cout << "no" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "yes" << endl;
}


Measured memory_bytes: 256
// B - Picture Frame
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> h >> w;
  // vector<vs> d(h, vs(w));
  vs d(h);
  rep(i, 0, h)
  {
    cin >> d[i];
  }
  a = h + 2;
  b = w + 2;
  rep(i, 0, b)
  {
    s += '#';
    t += '#';
  }
  cout << s << endl;
  rep(i, 0, h)
  {
    cout << '#' << d[i] << '#' << endl;
  }
  cout << t << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))

    dic = {}
    for a in A:
        if a in dic:
            dic[a] += 1
        else:
            dic[a] = 1
    
    ans = 0
    for key, value in dic.items():
        ans += (value * (value-1)) // 2
    
    for a in A:
        print(ans - dic[a] + 1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 24988
#include <stdio.h>

void swap(int *a, int *b)
{
    int temp;

    temp = *a;
    *a = *b;
    *b = temp;
}

int main(void)
{
    int i, w, n, a, b, amida[31];
    
    scanf("%d", &w);
    for (i = 1; i <= w; i++)
        amida[i] = i;

    scanf("%d", &n);
    while (n--) {
        scanf("%d,%d", &a, &b);
        swap(amida + a, amida + b);
    }

    for (i = 1; i <= w; i++)
        printf("%d\n", amida[i]);

    return 0;
}

Measured memory_bytes: 596
#include<stdio.h>

int main(){
    
    long long int a;
    scanf("%lld",&a);
    
    int i = 0;
    char str[100];
    
    while(a > 0){
        int temp = a % 26;
        
        if(temp == 0){
            str[i++] = 'z';
            a = (a/26) - 1;
        }else{
            str[i++] = (temp - 1) + 'a';
            a = a/26;
        }
    }
    str[i] = '\0';
    

    for(int j = i - 1;j >= 0;j--){
        printf("%c",str[j]);
    }
    
    
    return 0;
}

Measured memory_bytes: 1612
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

#define ll long long
const ll mod = 1000000007;

ll ruijo(ll x, ll n) {
    ll tmp = 1;
    while(n)
    {
        if(n&1) tmp = tmp * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return tmp;
}

int main()
{
    ll N;
    std::cin >> N;

    // 条件なし 10^N
    // 0を1個以上含む 含まないのは 9^N
    ll ans = 0;
    ans += ruijo(10, N);
    ans -= 2 * ruijo(9, N);
    ans += ruijo(8, N);
    ans = (ans % mod + mod) % mod;
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3604
#include<stdio.h>

int main(void)
{
int i,a,max1=0,max2=0,max3=0;
int k=0,w=0;

for(i=0;i<10;i++){
scanf("%d",&a);
if(max1<a){
max3=max2;
max2=max1;
max1=a;
}else if(max2<a){
max3=max2;
max2=a;
}else if(max3<a){
max3=a;
}
}
w=w+max2+max1+max3;

max1=0;
max2=0;
max3=0;

for(i=0;i<10;i++){
scanf("%d",&a);
if(max1<a){
max3=max2;
max2=max1;
max1=a;
}else if(max2<a){
max3=max2;
max2=a;
}else if(max3<a){
max3=a;
}
}
k=k+max2+max1+max3;

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

Measured memory_bytes: 596
import java.io.*;

public class Main {
  
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    String sl[] = s.split(" ");
    int a = Integer.parseInt(sl[0]);
    int b = Integer.parseInt(sl[1]);
    int x = Integer.parseInt(sl[2]);
    if(a <= x && x <= a + b)
    {
      System.out.println("YES");
    }
    else
    {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 22356
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;

    vector<map<string,LL>> dp(100);

    dp[0]["00A"]=1;
    dp[0]["00G"]=1;
    dp[0]["00C"]=1;
    dp[0]["00T"]=1;

    vector<string> c = {"A","G","C","T"};

    FOR(i,1,n){
        for(auto x : dp[i-1]){
            string s = x.first;
            LL num = x.second;

            REP(j,4){
                string next = s + c[j];
                if(next[1] == 'A' && next[2] == 'G' && next[3] == 'C'){
                    continue;
                }
                if(next[0] == 'A' && next[1] == 'G' && next[3] == 'C'){
                    continue;
                }
                if(next[1] == 'A' && next[2] == 'C' && next[3] == 'G'){
                    continue;
                }
                if(next[1] == 'G' && next[2] == 'A' && next[3] == 'C'){
                    continue;
                }
                if(next[0] == 'A' && next[2] == 'G' && next[3] == 'C'){
                    continue;
                }

                dp[i][next.substr(1)] += num;
                dp[i][next.substr(1)] %= MOD;
            }
        }
        //for(auto x : dp[i]){
        //    cerr<<x.first<<" "<<x.second<<",";
        //}
        //cerr<<endl;
    }

    LL result = 0;
    for(auto x : dp[n-1]){
        result += x.second;
        result %= MOD;
    }
    cout<<result<<endl;

    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

int main(){
  ll n, k;
  cin >> n >> k;
  cout << (n > k ? 0 : 1) << endl;
  return 0;
}



Measured memory_bytes: 3088
s, t = str(input()), str(input())

ls, lt = len(s), len(t)
dp = [[0] * (lt + 1) for _ in range(ls + 1)]
dp[0][0], dp[1][0], dp[0][1] = 0, 0, 0
for i in range(ls):
    for j in range(lt):
        dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j])
        if s[i] == t[j]:
            dp[i + 1][j + 1] = max(dp[i][j] + 1, dp[i + 1][j + 1])

ans = []
tmp_i, tmp_j = ls, lt
while tmp_i * tmp_j > 0:
    if dp[tmp_i][tmp_j] == dp[tmp_i - 1][tmp_j]:
        tmp_i -= 1
    elif dp[tmp_i][tmp_j] == dp[tmp_i][tmp_j - 1]:
        tmp_j -= 1
    else:
        tmp_i, tmp_j = tmp_i - 1, tmp_j - 1
        ans.append(s[tmp_i])
print(''.join(ans[::-1]))


Measured memory_bytes: 113372
#include<bits/stdc++.h>
using namespace std;
vector<int> G[100100];
int res[100100];
bool vis[100100];
int main()
{
  int N,M;
  cin>>N>>M;
  while(M--)
  {
    int A,B;
    cin>>A>>B;
    A--;
    B--;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  queue<int> Q;
  Q.push(0);
  vis[0]=true;
  while(!Q.empty())
  {
    int X=Q.front();
    Q.pop();
    for(int i=0;i<(int)(G[X].size());i++)
      if(!vis[G[X][i]])
      {
        vis[G[X][i]]=true;
        Q.push(G[X][i]);
        res[G[X][i]]=X+1;
      }
  }
  puts("Yes");
  for(int i=1;i<N;i++)
    cout<<res[i]<<endl;
  return 0;
}

Measured memory_bytes: 10568
#include<stdio.h>
#define M 100
#define inf (1<<21)
#define White 0
#define Black 1

int prim(void);

int n, G[M][M];
 
int main()
{
  int i,j;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  scanf("%d",&G[i][j]);
	  if(G[i][j] == -1) G[i][j] = inf;
	}
    }
  
  printf("%d\n",prim());
 
  return 0;
}
 
int prim()
{
  int color[M],d[M],p[M];
  int min,u,v,t=0;
  int i;
 
  for(i=0;i<n;i++)
    {
      color[i] = White;
      d[i] = inf;
      p[i] = -1;
    }
 
  d[0] = 0;
  p[0] = -1;
   
  while(1)
    {
      min = inf;
      for(i=0;i<n;i++)
	{
	  if(color[i] != Black && d[i] < min)
	    {
	      min = d[i];
	      u = i;
	    }
	}
      if(min == inf) break;
      color[u] = Black;
       
      for(v=0;v<n;v++)
	{
	  if(color[v] != Black && G[u][v] != inf)
	    {
	      if(G[u][v] < d[v])
		{
		  d[v] = G[u][v];
		  p[v] = u;
		}
	    }
	}
    }
  for(i=0;i<n;i++)
    {
      if(p[i] != -1) t += G[i][p[i]];
    }
  return t;
}

Measured memory_bytes: 636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication54
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int b = a[0] * a[1];
            int c = a[2] * a[3];
            if(b<=c)
            Console.WriteLine(c);
            if(b>c)
                Console.WriteLine(b);
        }
    }
}


Measured memory_bytes: 3032
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
const INF: f64 = std::f64::MAX;

#[derive(PartialEq, Debug)]
struct MinInt {
    value: f64,
}

impl Eq for MinInt {}

impl PartialOrd for MinInt {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        other.value.partial_cmp(&self.value)
    }
}

impl Ord for MinInt {
    fn cmp(&self, other: &MinInt) -> Ordering {
        other.value.partial_cmp(&self.value).unwrap()
    }
}

fn make_pair(x: f64, y: usize) -> (MinInt, usize) {
    (MinInt { value: x }, y)
}

#[derive(Debug, Clone)]
struct Edge {
    to: usize,
    cost: f64,
}

fn solve(edges: &Vec<Vec<Edge>>, start_idx: usize, num_apexes: usize) {
    let mut d = vec![INF; num_apexes];
    d[start_idx] = 0.0;
    let mut que = BinaryHeap::new();
    que.push(make_pair(0.0, start_idx));

    while let Some((u, v)) = que.pop() {
        if d[v] < u.value {
            continue;
        }
        for e in &edges[v] {
            if d[e.to] > d[v] + e.cost {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
    println!("{:?}", d[1]);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v = read_vec::<f64>();
    let (xs, ys, xt, yt) = (v[0], v[1], v[2], v[3]);
    let n: usize = read();
    let mut x = vec![0f64; n + 2];
    let mut y = vec![0f64; n + 2];
    let mut r = vec![0f64; n + 2];
    x[0] = xs;
    y[0] = ys;
    x[1] = xt;
    y[1] = yt;
    for i in 0..n {
        let v = read_vec::<f64>();
        x[i + 2] = v[0];
        y[i + 2] = v[1];
        r[i + 2] = v[2];
    }

    let mut edges: Vec<Vec<Edge>> = vec![Vec::new(); n + 2];

    let dist = |i: usize, j: usize| {
        let temp = ((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])).sqrt();
        if temp - r[i] - r[j] > 0.0 {
            temp - r[i] - r[j]
        } else {
            0.0
        }
    };

    for i in 0..x.len() {
        for j in i..x.len() {
            let d = dist(i, j);
            edges[i].push(Edge { to: j, cost: d });
            edges[j].push(Edge { to: i, cost: d });
        }
    }
    // println!("edges {:?}", &mut edges);
    solve(&edges, 0, n + 2);
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	string s, t, T;
	cin >> s >> t;
	T = s;

	for(int loop = 0; loop < 2; loop++){
		int n1 = 0, n2 = 0;
		bool ok = true;
		for(int i = 0; i < T.size(); i++){
			if(i % 2 == 0){
				while(n1 < s.size() && s[n1] != T[i]) n1++;
				if(n1 == s.size()){
					ok = false;
					break;
				}
				n1++;
			}
			else{
				while(n2 < t.size() && t[n2] != T[i]) n2++;
				if(n2 == t.size()){
					ok = false;
					break;
				}
				n2++;
			}
		}
		if(ok){
			cout << "Yes" << endl;
			return 0;
		}
		swap(s, t);
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3220
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k - 1] = tolower(s[k - 1]);
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3616
//omajinai
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//omajinai

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    string s;
    cin >> s;
    int count = 0;
    for(int i = 0;i < s.size()-1;i ++){
        if(s.at(i) != s.at(i+1)){
            count ++;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

 
int main() {
    string s;
    cin >> s;
    ll ans=0;
    vector<ll> a(2019,0),b(2019,0);
    rep(i,s.size()){
        int u=s[i]-'0';
        rep(j,2019){
            b[(j+u)%2019]=a[j];
        }
        a=b;
        a[u]++;
        ans+=a[0];
        rep(j,2019){
            b[(j*10)%2019]=a[j];
        }
        a=b;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <stdbool.h>
#include <bitset>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
using namespace std;

map<int, int> memorize;
int f(int n) {
    if (memorize.count(n)) {
        return memorize[n];
    }
    int x = (n % 2 == 0) ? n / 2 : 3 * n + 1;
    memorize[n] = x;
    return x;
}

int main(void) {
    int s;
    cin >> s;

    int i;
    set<int> ans;
    ans.insert(s);
    for(i = 2; ; ++i) {
        s = f(s);
        if(ans.count(s)) break;
        ans.insert(s);
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int k[15],s[15][15],p[15];

int main(void){
	int n,m,i,a,b,tmp,ans=0,flag;
	cin >> n >> m;
	for(a=0; a<m; ++a){
		cin >> k[a];
		for(b=0; b<k[a]; ++b){
			cin >> s[a][b];
			--s[a][b];
		}
	}
	for(a=0; a<m; ++a){
		cin >> p[a];
	}
	for(i=0; i<(1<<n); ++i){
		tmp = 0;
		for(a=0; a<m; ++a){
			flag = 0;
			for(b=0; b<k[a]; ++b){
				if(i&(1<<s[a][b])){
					++flag;
				}
			}
			if(flag%2==p[a]){
				++tmp;
			}
		}
		if(tmp == m){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 1<<18;
int n, b;
pii a[N][2];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, 1<<n){
    cin >> b;
    a[i][0] = mp(b, i);
    FOR(j, 0, n)if(i&(1<<j)){
      int k = i-(1<<j);
      if(a[i][0] > a[k][0]){
        maxs(a[i][1], a[k][0]);
      }else if(a[i][0] == a[k][0]){
        maxs(a[i][1], a[k][1]);
      }else{
        a[i][1] = max(a[i][0], a[k][1]);
        a[i][0] = a[k][0];
      }
    }
  }
  int ans = 0;
  FOR(i, 1, 1<<n){
    maxs(ans, a[i][0].fi + a[i][1].fi);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 7168
class MyDoublyLinkedList
  def initialize
    @orig = MyNode.new(nil, is_orig=true)
    @orig.next = @orig
    @orig.prev = @orig
  end

  def insert(key)
    node = MyNode.new(key)
    node.next = @orig.next
    @orig.next.prev = node
    @orig.next = node
    node.prev = @orig
  end

  def list_search(key)
    cur = @orig.next
    while ( !cur.is_orig && cur.key != key)
      cur = cur.next
    end
    cur
  end

  def delete_node(t)
    return if t.is_orig

    t.prev.next = t.next
    t.next.prev = t.prev
  end

  def delete_first
    delete_node(@orig.next)
  end

  def delete_last
    delete_node(@orig.prev)
  end

  def delete_key(key)
    delete_node(list_search(key))
  end

  def exec(command, key=nil)
    case command
    when "insert"
      insert(key)
    when "delete"
      delete_key(key)
    when "deleteFirst"
      delete_first()
    when "deleteLast"
      delete_last()
    end
  end

  def print
    keys = []
    cur = @orig.next
    while ( !cur.is_orig)
      keys << cur.key
      cur = cur.next
    end
    puts keys.join(' ')
  end
end

class MyNode
  attr_accessor :key, :prev, :next
  attr_reader :is_orig
  def initialize(key, is_orig=false)
    @key = key
    @is_orig = is_orig
  end
end

n = gets.to_i
dll = MyDoublyLinkedList.new
n.times do
  command, key = gets.split
  key = key.to_i
  dll.exec(command, key)
end

dll.print


Measured memory_bytes: 107340
A,B,K = map(int,input().split())
se =[]
for i in range(min(K,B-A)):
  se += [A+i]
for j in range(min(K,B-A)):
  se += [B-j]
result=list(set(se))
result=sorted(result)
for p in range(len(result)):
    print(result[p])
if A==B:
  print(A)

Measured memory_bytes: 3064
n=gets.chomp.to_i

obj = {}

n.times do
    s = gets.chomp
    if obj[s].nil?
        obj[s] = 1
    else
        obj[s] += 1   
    end
end

mx = obj.values.max
obj.keep_if{|_, value| value==mx}.keys.sort.each{|s| puts s}

Measured memory_bytes: 36328
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//関係性は隣接行列で記録
//過半数：N/2.0で判定
//ある量からある量を引く系の問題：端から定義してやる
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll N, M; cin >> N >> M;
	vector<ll> H(N+1); for (int i = 1; i <= N; i++) cin >> H[i];
	vector<ll> A(M), B(M); rep(i, M)cin >> A[i] >> B[i];

	vector<ll> t(N+1);
	rep(i, M) {
		if (H[A[i]] > H[B[i]]) t[B[i]] = 1;
		else if (H[A[i]] < H[B[i]]) t[A[i]] = 1;
		else {
			t[A[i]] = 1;
			t[B[i]] = 1;
		}
	}

	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		if (t[i] == 0) ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 14352
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, a[20][20], val[100100], f[100000];
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> a[i][j];
    int tmp = (1 << n);
    for (int mask = 1; mask < tmp; mask++)
    {
        for (int i = 0; i < n; i++)
            if ((mask >> i) & 1)
                for (int j = i + 1; j < n; j++)
                    if ((mask >> j) & 1)
                        val[mask] += a[i][j];
    }
    for (int mask = 1; mask < tmp; mask++)
    {
        f[mask] = max(f[mask], val[mask]);
        for (int preMask = mask; preMask > 0; preMask = (preMask - 1) & mask)
            f[mask] = max(f[mask], f[preMask] + f[(mask ^ preMask)]);
    }
    cout << f[tmp - 1];
}


Measured memory_bytes: 4680
#include <bits/stdc++.h>
using namespace std;
char A[1001],B[1001];
bool jg(int in){
	for(int i=0; i<strlen(B); i++)
		if(A[in+i] != B[i]) return 0;
	return 1;
}
int main()
{	
	scanf("%s%s",A,B);
	for(int i=0; i<strlen(A); i++)
		if(jg(i)) cout<<i<<endl;
	return 0;
}



Measured memory_bytes: 3164
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,c;
    string s,s1;
    cin >> s >> s1;
    if(s[0] == s1[2] && s[1] == s1[1] && s[2] == s1[0])
        cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

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

	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	for (int i = 0; i < K; i++) {
		vector<int> next(N + 1, 0);
		for (int j = 0; j < N; j++) {
			next[max(0, j - A[j])]++;
			next[min(N, j + A[j] + 1)]--;
		}
		for (int i = 0; i < N; i++) {
			next[i + 1] += next[i];
		}
		next.pop_back();
		swap(next, A);
		if (A == vector<int>(N, N)) break;
	}

	for (const auto& e : A) cout << e << "\n";

	return 0;
}



Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

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

    int n;
    long long int a[200000];
    long long int ans = 0;
    long long int l=0, r=0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        r += a[i];
    }
    l = a[0];
    r -= a[0];
    ans = abs(l-r);
    for(int i = 1; i < n-1; i++){
        l += a[i];
        r -= a[i];
        if(ans > abs(l-r))  ans = abs(l-r);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1792
import 'dart:io';
 
void main(List<String> args){
  List<String> A = stdin.readLineSync().split(' ').toList();
  int S = int.parse(A[0] + A[1]);
  String ans = "No";
  for(int i=0; i<1000; ++i){
  	if(i*i==S) ans = "Yes";
  }
  print(ans);
}

Measured memory_bytes: 13120
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, i, c = 0;
    cin >> n;
    int a[n + 2];
    for (i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (i = 0; i < n; i++)
    {


        if (a[i] % 2 == 0)
        {
            if (a[i] % 3 != 0 && a[i] % 5 != 0)
             {
                c = 1;
                break;
            }
        }

    }
    if (c == 1)
    {
        cout << "DENIED" << endl;
    } else
    {
        cout << "APPROVED" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    transportation = [int(input()) for _ in range(5)]

    time = [0] * 5

    for i in range(5):
        if N % transportation[i] == 0:
            time[i] = N // transportation[i]
        else:
            time[i] = N // transportation[i] + 1

    ans = max(time) + 4

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//const int mod = 1e9+7;
const int N = 100010;
ll lfs[N], n;
ll suff[N];
inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

ll solve() {
    for(int i = n; i >= 0; i --) {
        suff[i] = suff[i+1] + lfs[i];
    }
    ll cnt = 0;
    ll curr = 1;
    for(int i = 0; i <= n; i ++) {
        cnt += curr;
        //cout << i << " " << curr << endl;
        if(curr <= 0) return -1;
        if(curr > suff[i]) return -1;
        else if(curr <= suff[i]){
            curr -= lfs[i];
            if(curr < 0) return -1;
            if(2*curr <= suff[i+1]) curr*=2;
            else if(curr > suff[i+1]) return -1;
            else if(2*curr > suff[i+1]) curr = suff[i+1];
        }
    }
    return cnt;
}

int main()
{
    quickread();
    cin >> n;
    for(int i = 0; i <= n; i ++) cin >> lfs[i];
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 5144
#include <bits/stdc++.h>
#define ln(S) (S).length()
using namespace std;

typedef long long llint;

int n;
int a[100100];

int main(){
	cin >> n;

	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
	}

	int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (a[a[i]] == i)
			ans++;
	}

	cout << ans/2;

	return 0;
}

Measured memory_bytes: 640
# python 3.8.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
import numpy as np
from decimal import *
from collections import deque
from math import gcd
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def lcm(a,b):return (a*b) // gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')

n = int(input())

A = list(map(int, input().split()))

ans = 1
for i in range(n):
  if (A[i] == 0):
    print(0)
    exit()
    
for i in range(n):
    ans *= A[i]
   
    if ans > 1000000000000000000:
        ans = -1
        break

print(ans)


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

int main() {
  int a[20] = {0};

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

  if (a[5] == 2 && a[7] == 1) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }

  return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int N, A[110];

int sum;

int f(int x){
    return std::abs(sum - A[x] * N);
}   

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
        sum += A[i];
    }

    int mn_f = 0;
    for(int i=1;i<N;++i){
        if(f(mn_f) > f(i)){
            mn_f = i;
        }
    }

    std::cout << mn_f << std::endl;
}


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

for i in range(N-1):
  if A[i] == A[i+1]:
    count += 1
  i += 1

if count > 0:
  print('NO')
if count == 0:
  print('YES')

Measured memory_bytes: 31168