akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string s;
    cin >> s;
    ll K;
    cin >> K;
    REP(i, s.length()) {
        if(s[i] == 'a') {
            continue;
        }
        int cnt = 'z' - 'a' - (s[i] - 'a') + 1;
        // cout << cnt << endl;
        if(K - cnt >= 0) {
            K -= cnt;
            s[i] = 'a';
        }
    }
    if(K > 0) {
        K %= 'z' - 'a' + 1;
        s[s.length() - 1] = s[s.length() - 1] + K;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

bool solve() {
    int a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) { return false; }
    if (a < b) { swap (a, b); }

    int step = 0;
    while (b > 0) {
        ++step;
        int t = a % b;
        a = b;
        b = t;
    }
    cout << a << ' ' << step << endl;
    return true;
}

int main() {
    while(solve());
    return 0;
}

Measured memory_bytes: 3016
a = [list(map(int ,input().split())) for _ in range(3)]
n = int(input())

ans = [[0] * 3 for _ in range(3)]

for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] ==  b:
                ans[j][k] = 1

state = False
for i in range(3):
    num = 0
    for j in range(3):
        num += ans[i][j]
    
    if num == 3:
        state = True

for i in range(3):
    num = 0
    for j in range(3):
        num += ans[j][i]
    
    if num == 3:
        state = True

if ans[0][0] + ans[1][1] + ans[2][2] == 3:
    state = True

if ans[0][2] + ans[1][1] + ans[2][0] == 3:
    state = True

if state:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9128
from operator import itemgetter

n = int(input())
ab =  [list(map(int,input().split())) for i in range(n)]

ab = sorted(ab,key=itemgetter(1),reverse = False)

cnt = 0
flag = True
for i in range(n):
    cnt += ab[i][0]
    if cnt > ab[i][1]:
        flag = False
if flag :
    print('Yes')
else:
    print('No')


Measured memory_bytes: 55268
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<time.h>
#include<cstdlib>
typedef long long ll;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mm(a) memset(a,0,sizeof(a))
#define lr rt<<1
#define rr rt<<1|1
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0);
#define inf 0x3f3f3f3f
#define eqs 1e-8
#define lb(x) (x&(-x))
#define ch(a) (int(a-'0'))
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef pair<int,int> pii;
const double pi=acos(-1);
const int maxn=201000;
//const ll Mod=1000000007;
//const ll Mod=6597069766657;
using namespace std;
//const ll Mod=2e17;

int a[20][2000];
int sum[20][2000];
int h,w,k;
string s;
int gt(int x1,int y1,int x2,int y2)
{
    return sum[x2][y2]-sum[x2][y1-1]-sum[x1-1][y2]+sum[x1-1][y1-1];
}
int zd=10000000;

void dfs(int x1,int x2,int step,vector<pii>vis)
{
    int ans=0;
    if(x2==h)
    {
        vis.push_back(pii(x1,x2));
        int l=1,r=1;
        while(l<=w)
        {
            r=l;
            while(1)
            {
                int f=0;
                for(int i=0;i<vis.size();i++)
                {
                    int L=vis[i].first;
                    int R=vis[i].second;
                    if(gt(L,l,R,r)>k||r>w)
                    {
                        f=1;
                        break;
                    }
                }
                if(f)
                {
                    r--;
                    break;
                }
                r++;
            }
            if(r<l)
                return;
            if(r==w)
            {
                zd=min(step+ans,zd);
                return;
            }
            l=r+1;
            ans++;
        }
        return;
    }
    dfs(x1,x2+1,step,vis);
    
    vector<pii>v=vis;
    vis.push_back(pii(x1,x2));
    dfs(x2+1,x2+1,step+1,vis);
    
    return ;
}

int main()
{
    sync;
    cin>>h>>w>>k;
    for(int i=1;i<=h;i++)
    {
        cin>>s;
        for(int j=1;j<=w;j++)
        {
            a[i][j]=int(s[j-1]-'0');
        }
    }
    
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            sum[i][j]=sum[i-1][j]+sum[i][j-1]+a[i][j]-sum[i-1][j-1];
        }
    }
    vector<pii>vis;
    vis.clear();
    dfs(1,1,0,vis);
    cout<<zd<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, D[301010];
//---------------------------------------------------------------------------------------------------
int check() {
    int ok = 0;
    rep(i, 0, N) {
        if (ok < i) return 0;
        chmax(ok, i + D[i] / 10);
    }
    return 1;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> D[i];

    if (!check()) {
        printf("no\n");
        return;
    }

    reverse(D, D + N);

    if (!check()) {
        printf("no\n");
        return;
    }

    printf("yes\n");
}


Measured memory_bytes: 4292
#include <stdio.h>
#define A 50

int array[A];

int fibonacci(int);

int main(){
  int n, i;

  for(i = 0; i <= A; i++) array[i] = -1;
  scanf("%d", &n);
  printf("%d\n", fibonacci(n));
  
  return 0;
}
int fibonacci(int n){
  if(n == 0 || n == 1) return array[n] = 1;
  if(array[n] != -1) return array[n];
  return array[n] = fibonacci(n - 1) + fibonacci(n - 2); 
}

/*
#include <stdio.h>

int makeFibonacci(int);

int main(){
  int n;

  scanf("%d", &n);
  printf("%d\n", makeFibonacci(n));
    
  return 0;
}
int makeFibonacci(int n){
  int i, array[50];
  
  array[0] = 1;
  array[1] = 1;
  for(i = 2; i <= n; i++){
    array[i] = array[i - 1] + array[i - 2]; 
  }
  return array[i];
}
*/



Measured memory_bytes: 2052
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int a = 0;
		int b = 0;
		int c = 0;
		int ans = 0;

		Scanner in = new Scanner(System.in);

		a = in.nextInt();
		b = in.nextInt();
		c = in.nextInt();

		while(a<=b){
			if (c % a == 0){
				ans++;
			}else{

			}
		a++;
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 26104
#include <cstdio>
#include <cstring>
#define max(a,b) ((a)>=(b)?(a):(b))
#define abs(x) ((x)>=0?(x):-(x))
int dp[200][200],A[200],B[200],C[200],T[200];
int main() {
	int D,N;
	scanf("%d %d",&D,&N);
	for(int i=0;i<D;i++) scanf("%d",&T[i]);
	for(int i=0;i<N;i++) scanf("%d %d %d",&A[i],&B[i],&C[i]);
	memset(dp,0,sizeof(dp));
	for(int i=1;i<D;i++) for(int j=0;j<N;j++) {
		if(A[j]<=T[i] && T[i] <=B[j]) {
			for(int k=0;k<N;k++) {
				if(A[k]<=T[i-1] && T[i-1]<=B[k]) {
					dp[i][j]=max(dp[i][j],dp[i-1][k]+abs(C[j]-C[k]));
				}
			}
		}
	}
	int ans=-1;
	for(int i=0;i<N;i++) ans=max(ans,dp[D-1][i]);
	printf("%d\n",ans);
}

Measured memory_bytes: 1192
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> PI;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second


signed main(){
	
	ll h,w;
	cin >> h >> w;
	string s;
	
	rep(i,0,h){
		rep(j,0,w){
			cin >> s;
			
			if(s == "snuke"){
				cout << (char)(j+'A') << i+1 << endl;
			}
			
		}
	}
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 2147483647
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A < C && B > C) {
        cout << "Yes" << endl;
    }
    else if (A > C && B < C) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int INF=1001001001;
const int MOD=1000000007;

int main() {
  int h,n;
  cin>>h>>n;
  vector<P> v(n);
  rep(i,n){
    int a,b;
    cin>>a>>b;
    v[i]=P(a,b);
  }
  vector <int> d(h+10001);
  rep(i,h+10001)d[i]=INF;
  d[0]=0;
  rep(i,h){
    rep(j,n){
      int anow,bnow;
      anow=v[j].first;
      bnow=v[j].second;
      d[i+anow]=min(d[i+anow],d[i]+bnow);
    }
  }
  int ans=INF;
  for(int i=h;i<h+10001;i++){
  //  cout<<d[i]<<endl<<'d';
    ans=min(ans,d[i]);
  }

  cout<<ans;
}


Measured memory_bytes: 384
#include <stdio.h>
    #include <math.h>
     
    int main(){
              
      int n;
      char s[128];
      char t[128];
      int i;
      char st[256];
      
      scanf("%d",&n);
      
      for(i=0; i<n; i++){
      	scanf("%s %s",s,t);
      }
      
      for(i=0; i<n; i++){
      	st[i*2] = s[i];
        st[(2*i)+1] = t[i];
      }
      st[2*n] = '\0';
   
      printf("%s",st);
      return 0;
     
    }

Measured memory_bytes: 128
#include"iostream"
#include"vector"
using namespace std;
class branch
{
public:
  int key;
  branch *p;
  branch *left,*right;
  branch(){}
  branch(int key,branch *p)
  {
    this->key=key;
    this->p=p;
    this->left=NULL;
    this->right=NULL;
  }
};
branch *tree;
void insert(int z)
{
  branch *buf;
  branch *y=NULL;
  branch *x=tree;
  while(x!=NULL)
    {
      y=x;
      if(z<x->key)
        {
          x=x->left;
        }
      else
        {
          x=x->right;
        }
    }
  buf=new branch(z,y);
  if(y==NULL)tree=buf;
  else if(buf->key<y->key)y->left=buf;
  else y->right=buf;
}
int search(int key,branch *p)
{
  if(p==NULL)return 0;
  if(p->key==key)return 1;
  if(key<p->key)
    {
      return search(key,p->left);
    }
  else
    {
      return search(key,p->right);
    }
  return 0;
}
int preParse(branch *p)
{
  if(p==NULL)
    {
      return 0;
    }
  cout<<" "<<p->key;
  preParse(p->left);
  preParse(p->right);
}
int find(int key)
{
  branch *p=tree;
  return search(key,p);
}
int inParse(branch *p)
{
  if(p==NULL)
    {
      return 0;
    }
  inParse(p->left);
  cout<<" "<<p->key;
  inParse(p->right);
}
int postParse(branch *p)
{
  if(p==NULL)
    {
      return 0;
    }
  postParse(p->left);
  postParse(p->right);
  cout<<" "<<p->key;
}
int main()
{
  tree=NULL;
  int m;
  char cmd[20];
  cin>>m;
  for(int i=0;i<m;i++)
    {
      cin>>cmd;
      if(cmd[0]=='i')
        {
          int n;
          cin>>n;
          insert(n);
        }
      else if(cmd[0]=='p')
        {
          inParse(tree);
          cout<<endl;
          preParse(tree);
          cout<<endl;
        }
      else if(cmd[0]=='f')
        {
          int n;
          cin>>n;
          if(find(n))cout<<"yes"<<endl;
          else cout<<"no"<<endl;
        }
    }
  return 0;
}


Measured memory_bytes: 21852
n, k = map(int, input().split())
p = list(map(int, input().split()))

prev = sum(p[1:k])
current = sum(p[1:k])
ind = 0

for i in range(1, n - k + 1):
    current = current - p[i - 1] + p[i + k - 1]

    if prev < current:
        prev = current
        ind = i

total = 0
for i in range(ind, ind + k):
    total += p[i] / 2 + 0.5

print(total)



Measured memory_bytes: 24804
package main
import(
  "fmt"
)
func main(){
  var k, n, m, i int
  fmt.Scan(&k, &n, &m)
  for i=n;i<=m;i++{
    if i%k==0{
      fmt.Println("OK")
      return
    }
  }
  fmt.Println("NG")
}


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

const int maxn = 100005;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

int n, m, sum[maxn];

struct node
{
	int Id, x, y1, y2;

	bool operator < (const node &a) const {
		return x != a.x ? x < a.x : !Id;
	}
} s[maxn * 65];
int cnt;

int Sum[maxn];

void insert(int x, int a)
{
	++x;
	while (x <= m + 1) {
		Sum[x] += a;
		x += x & (-x);
	}
}

int query(int x)
{
	int res = 0; ++x;
	while (x) {
		res += Sum[x];
		x -= x & (-x);
	}
	return res;
}

int main()
{
	n = gi(); m = gi();
	for (int i = 1; i <= n; ++i) s[++cnt] = (node) {0, gi(), 0, gi()};
	for (int i = 2, j; i <= m; ++i) {
		for (j = i; j <= m; j += i)
			s[++cnt] = (node) {-i, j - i, j - i + 1, j - 1}, s[++cnt] = (node) {i, j - 1, j - i + 1, j - 1};
		j -= i; if (j + 1 <= m) s[++cnt] = (node) {-i, j, j + 1, m}, s[++cnt] = (node) {i, m, j + 1, m};
	}

	assert(cnt <= maxn * 60);
	stable_sort(s + 1, s + cnt + 1);
	for (int i = 1; i <= cnt; ++i)
		if (!s[i].Id) insert(s[i].y2, 1);
		else {
			if (s[i].Id < 0) sum[-s[i].Id] -= query(s[i].y2) - query(s[i].y1 - 1);
			else sum[s[i].Id] += query(s[i].y2) - query(s[i].y1 - 1);
		}
	for (int i = 1; i <= m; ++i) printf("%d\n", n - sum[i]);

	return 0;
}


Measured memory_bytes: 65408
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード(アルファベット順,bits/stdc++.hは使わない派閥)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素



int main(){
    int N,M;
    cin >> N >> M;
    vector<int> P(M);
    vector<ll> Y(M);
    REP(i, M){
        cin >> P[i] >> Y[i];
    }
    unordered_map<int, vector<ll>> mp;
    REP(i, M){
        mp[P[i]].push_back(Y[i]);
    }

    for(auto& com : mp){
        std::sort(com.second.begin(), com.second.end());
    }

    REP(i, M){
        std::ostringstream sout;
        sout << std::setfill('0') << std::setw(6) << P[i];
        std::string first = sout.str();

        int num = std::distance(mp[P[i]].begin(), lower_bound(mp[P[i]].begin(), mp[P[i]].end(), Y[i]))+1;

        std::ostringstream sout2;
        sout2 << std::setfill('0') << std::setw(6) << num;
        std::string second = sout2.str();

        cout << first + second << endl;
    }
}


Measured memory_bytes: 11428
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

typedef struct {
	int Up;
	int Sorth;
	int East;
	int West;
	int North;
	int Down;
}DICE;/*
	  DICE North(DICE *t);
	  DICE Sorth(DICE *t);
	  DICE East(DICE *t);
	  DICE West(DICE *t);
	  DICE Rot(DICE *t);
	  */
void assignment(DICE *t);
int main()
{
	unsigned int i, k;
	int up, front;
	DICE Dice1, shoki;
	assignment(&Dice1);
	shoki = Dice1;
	scanf("%d", &k);
	for (i = 0; i < k; i++){
		scanf("%d %d", &up, &front);
		if (up == Dice1.Up){
			if (front == Dice1.Sorth) printf("%d\n", Dice1.East);
			if (front == Dice1.North){ printf("%d\n", Dice1.West); }
			if (front == Dice1.East){ printf("%d\n", Dice1.North); }
			if (front == Dice1.West){ printf("%d\n", Dice1.Sorth); }
		}
		if (up == Dice1.Down){
			if (front == Dice1.Sorth){ printf("%d\n", Dice1.West); }
			if (front == Dice1.North){ printf("%d\n", Dice1.East); }
			if (front == Dice1.East){ printf("%d\n", Dice1.Sorth); }
			if (front == Dice1.West){ printf("%d\n", Dice1.North); }
		}

		if (up == Dice1.Sorth){
			if (front == Dice1.West){ printf("%d\n", Dice1.Down); }
			if (front == Dice1.East){ printf("%d\n", Dice1.Up); }
			if (front == Dice1.Up){ printf("%d\n", Dice1.West); }
			if (front == Dice1.Down){ printf("%d\n", Dice1.East); }
		}
		if (up == Dice1.North){
			if (front == Dice1.West){ printf("%d\n", Dice1.Up); }
			if (front == Dice1.East){ printf("%d\n", Dice1.Down); }
			if (front == Dice1.Up){ printf("%d\n", Dice1.East); }
			if (front == Dice1.Down){ printf("%d\n", Dice1.West); }
		}
		if (up == Dice1.East){
			if (front == Dice1.Sorth){ printf("%d\n", Dice1.Down); }
			if (front == Dice1.North){ printf("%d\n", Dice1.Up); }
			if (front == Dice1.Up){ printf("%d\n", Dice1.Sorth); }
			if (front == Dice1.Down){ printf("%d\n", Dice1.North); }
		}
		if (up == Dice1.West){
			if (front == Dice1.Sorth){ printf("%d\n", Dice1.Up); }
			if (front == Dice1.North){ printf("%d\n", Dice1.Down); }
			if (front == Dice1.Up){ printf("%d\n", Dice1.North); }
			if (front == Dice1.Down){ printf("%d\n", Dice1.Sorth); }
		}
	}

	return 0;
}

void assignment(DICE *t){
	int i, as, a[6];
	DICE temp;
	for (i = 0; i < 6; i++){
		scanf("%d", &as);
		a[i] = as;
	}
	t->Up = a[0], t->Sorth = a[1], t->East = a[2], t->West = a[3], t->North = a[4], t->Down = a[5];
}
/*
DICE North(DICE *t){
DICE temp = { t->Sorth, t->Down, t->East, t->West, t->Up, t->North };
return temp;
}
DICE Sorth(DICE *t){
DICE temp = { t->North, t->Up, t->East, t->West, t->Down, t->Sorth };
return temp;
}
DICE East(DICE *t){
DICE temp = { t->West, t->Sorth, t->Up, t->Down, t->North, t->East };
return temp;
}
DICE West(DICE *t){
DICE temp = { t->East, t->Sorth, t->Down, t->Up, t->North, t->West };
return temp;
}
DICE Rot(DICE *t){
DICE temp = { t->Up, t->East, t->North, t->Sorth, t->West, t->Down };
return temp;
}
*/

Measured memory_bytes: 596
from collections import defaultdict


n = int(input())

count = defaultdict(int)

for x in map(str, range(1, n + 1)):
    head = x[0]
    tail = x[-1]
    count[(head, tail)] += 1

ans = 0
# if do not, RuntimeError: dictionary changed size during iteration
items = list(count.items())
for (head, tail), c in items:
    ans += c * count[(tail, head)]

print(ans)

Measured memory_bytes: 3316
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T chmin(T& l, T r) {
    return l = min(l, r);
}
template<typename T>
T chmax(T& l, T r) {
    return l = max(l, r);
}
// ============ template finished ============

int main()
{
    ll N, M, X;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M));
    rep(i, N) {
        cin >> C[i];
        rep(j, M)cin >> A[i][j];
    }

    ll res = INFL;
    rep(way, 1 << N) {
        ll cost = 0;
        vector<ll> understands(M, 0);
        rep(book, N) if ((way >> book) & 1) {
            cost += C[book];
            rep(kind, M)understands[kind] += A[book][kind];
        }
        for (auto understand : understands) {
            if (understand < X) {
                goto fail;
            }
        }
        res = min(res, cost);
fail:;
    }


    cout << (res == INFL ? -1 : res) << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

// 300, 20min?

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

string S;
vector<string> ans_pattern;

signed main()
{
    cin >> S;

    // AKIHABARA に A は 4 つ → 2^4=16パターンの正解がある
    // 全パターンを列挙
    for(int i = 0; i < 16; ++i) {
        string cand = "";
        if((i >> 0) & 1) { cand += "A"; }
        cand += "KIH";
        if((i >> 1) & 1) { cand += "A"; }
        cand += "B";
        if((i >> 2) & 1) { cand += "A"; }
        cand += "R";
        if((i >> 3) & 1) { cand += "A"; }
        ans_pattern.push_back(cand);
    }

    // S が正解パターンか比較
    for(auto& pat : ans_pattern) {
        if(pat == S) {
            printf("YES\n");
            return 0;
        }
    }

    printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int gcd(int x, int y)
{
    int t;

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

int main() {
    long long int K;
    long long int SUM = 0;
    scanf("%lld",&K);
    int s = 0;
    int t = 0;

    for(int i = 1; i <= K; ++i) {
        for (int j = 1; j <= K; ++j) {
            s = gcd(i,j);
            for (int k = 1; k <= K; ++k) {


                SUM +=gcd(s,k);;
            }
        }
    }

    printf("%lld",SUM);
    return 0;
}

int A(){
    int N;

    scanf("%d",&N);

    while(N){
        if(N % 10 == 7){
            printf("Yes");
            return 0;
        }

        N = N / 10;
    }
    printf("No");

    return 0;
}

int B(){
    long long int N;
    long long int SUM = 0;

    scanf("%lld",&N);
    for(long long int i = 1; i <= N; ++i){
        if(i % 3 == 0 || i % 5 == 0){
        }
        else{
            SUM += i;
        }
    }
    printf("%lld",SUM);
    return 0;
}


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

void fnInput(vector<int>& rvnRally)
{
  int nRallySiz;
  cin >> nRallySiz;
  rvnRally.resize(nRallySiz);

  for (int& rnRally : rvnRally)
    cin >> rnRally;
}
  
int fnCostGet(const vector<int>& cnrvnRally)
{
  int nAverage = (double)accumulate(begin(cnrvnRally), end(cnrvnRally), 0) / cnrvnRally.size() + 0.5;
  int nCost = 0;

  for (int nRally : cnrvnRally)
    nCost += (nAverage - nRally) * (nAverage - nRally);

  return nCost;
}
  
int main()
{
  vector<int> vnRally;

  fnInput(vnRally);
  cout << fnCostGet(vnRally) << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
def line():return sys.stdin.readline().strip()
def a(n,k,s):
    if k == 0:print(s[1:])
    elif k > 0:
        for i in range(1,n + 1)[::-1]:
            a(i,k - i,s + " " + str(i))
while True:
    n = int(line())
    if n == 0:break
    a(n,n,"")

Measured memory_bytes: 7780
import java.math.BigInteger;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static final boolean debugMode = false;

	static final long DIV_INF = 1000000007l;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();

		if (s.length() + 1 != t.length()) {
			System.out.println("No");
			return;
		}

		if (t.substring(0, t.length() - 1).equals(s)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

	static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static Long readLong(Scanner sc) {
		return Long.parseLong(sc.next());
	}

	static void log(String s) {
		if (debugMode) {
			System.out.println(s);
		}
		return;
	}
}

class KrmlUtil {
	// a >= b
	static int gcd(int a, int b) {
		while (true) {
			if (b == 0)
				break;

			int mod = a % b;
			a = b;
			b = mod;
		}
		return a;
	}

	// a >= b
	static int lcm(int a, int b) {
		return a * b / gcd(a, b);
	}

	// a >= b
	static long gcd(long a, long b) {
		while (true) {
			if (b == 0)
				break;

			long mod = a % b;
			a = b;
			b = mod;
		}
		return a;
	}

	// a >= b
	static long lcm(long a, long b) {
		return a * b / gcd(a, b);
	}

	static BigInteger gcd(BigInteger a, BigInteger b) {
		return a.gcd(b);
	}

	static BigInteger lcm(BigInteger a, BigInteger b) {
		return a.divide(a.gcd(b)).multiply(b);
	}
}

class Pair {
	private int x;
	private int y;

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public Pair() {

	}

	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}

}


Measured memory_bytes: 35748
S=list(input())
MOD=10**9+7
dp=[[0]*13 for i in range(len(S)+1)]
dp[0][0]=1
for i in range(len(S)):
    if S[i]=="?":
        for j in range(10):
            for k in range(13):
                dp[i+1][(10*k+j)%13]+=dp[i][k]%MOD
    else:
        a=int(S[i])
        for k in range(13):
            dp[i+1][(10*k+a)%13]+=dp[i][k]%MOD
print(dp[len(S)][5]%MOD)

Measured memory_bytes: 66808
#include <bits/stdc++.h>
#define MAX 100005
#define INF 1e9
using namespace std;

typedef long long ll;

int arr[MAX];

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

    cin>>n;

    cin>>arr[0];
    int g = arr[0];
    for(int i = 1; i < n; i++){
        cin>>arr[i];
        g = __gcd(g, arr[i]);
    }    

    cout<<g<<endl;

    return 0;
}

Measured memory_bytes: 640
import numpy as np
n,m,c= map(int,input().split())
b = list(map(int,input().split()))
b=np.array(b)
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
a = np.array(a)
ans=0
for i in range(n):
  if sum(a[i] * b) + c > 0:
    ans +=1
print(ans)

Measured memory_bytes: 21784
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] a = new int[N];
        boolean[] d = new boolean[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt()-1;
        }
        int current = 0;
        int answer = 0;
        while(current != 1 && !d[current]) {
            d[current] = true;
            current = a[current];
            answer += 1;
        }
        if (current == 1) {
            System.out.println(answer);
        } else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 51072
#include<cstdio>


int main(void)
{
	int n;
	char a[100+2], b[100+2], c[100+2];
	

	while(scanf("%d\n%100[a-z]\n%100[a-z]\n%100[a-z]", &n, a, b, c)==4)
	{
		int ans=0;

		for(int i=0;i<n;i++)
		{
			int add=2;
			if(a[i]==b[i])
			{
				if(b[i]==c[i]) add=0;
				else add=1;
			}
			else
			{
				if(b[i]==c[i]) add=1;
				if(a[i]==c[i]) add=1;
			}
			ans+=add;
		}
		printf("%d\n", ans);
	}

	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
  int n;
  scanf("%d", &n);
  int a[n];
  int b[n];
  int c[n-1];
  for(int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i]--;
  }
  for(int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
  }
  for(int i = 0; i < n - 1; i++) {
    scanf("%d", &c[i]);
  }

  int satisfied = b[a[0]];

  for(int i = 1; i < n; i++) {
    satisfied += b[a[i]];
    if(a[i] == a[i-1] + 1) {
      satisfied += c[a[i-1]];
    }
  }
  printf("%d\n", satisfied);
  return 0;
}


Measured memory_bytes: 128
"use strict";

function main(input) {
  input = input.trim().split("\n");
  const N = Number(input[0]);
  let line2 = input[1].split(" ");
  let ans = [];
  for (let i = 0; i < N; i++) {
    ans.push(line2[0].split("")[i]);
    ans.push(line2[1].split("")[i]);
  }
  console.log(ans.join(""));
}

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;



typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k, q;
    string s;
    cin >> n >> k >> q;
    lvec v(n, 0);
    for (ll i=0; i<q; i++){
        ll a;
        cin >> a;
        v[a-1]++;
    }

    for (ll i = 0; i<n; i++){
        if (q - v[i] >= k) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}


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

int N;
const int MAX_N = 100005;
const int MAX_V = 100005;
vector<int> edges[MAX_N * 2];
bool visited[MAX_N * 2];

void dfs(int v, vector<int> &cnt) {
  if(visited[v]) return;
  visited[v] = true;
  cnt[v/MAX_V]++;
  for(int u : edges[v]) dfs(u, cnt);
}

int main() {
  cin >> N;
  rep(i, N) {
    int x, y;
    cin >> x >> y;
    edges[x].push_back(y+MAX_V);
    edges[y+MAX_V].push_back(x);
  }
  long long ans=0;
  rep(i, MAX_N*2) {
    if(visited[i]) continue;
    vector<int> cnt(2);
    dfs(i, cnt);
    ans += (long long)cnt[0]*cnt[1];
  }
  cout << ans-N << endl;
  return 0;
}



Measured memory_bytes: 10240
a, b, k = map(int, input().split())
if b - a < k:
    for i in range(a,b+1):
        print(i)
else:
    a_list = [i for i in range(a, a+k)]
    b_list = [i for i in range(b, b-k, -1)]
    c = set(a_list + b_list)
    sort_c =sorted(c)
    for i in sort_c:
        print(i)

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

#define ll long long

struct edge
{
    int to;
    ll cost;
};

vector<edge> tree[100010];
ll cost_k[100010];

void dfs(int v, int par, ll dist)
{
    cost_k[v] = dist;

    for (int i = 0; i < tree[v].size(); i++)
    {
        edge e = tree[v][i];
        if (e.to == par)
            continue;
        dfs(e.to, v, dist + e.cost);
    }
}

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

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

    int Q, K;
    cin >> Q >> K;
    K--;

    dfs(K, -1, 0);

    for (int i = 0; i < Q; i++)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << cost_k[x] + cost_k[y] << endl;
    }
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;


const int MX = 3005, MOD = 998244353;
int N, S, A[MX], mem[MX][MX];

int dp(int idx, int sum) {
	if (sum > S)
		return 0;
	if (idx == N + 1)
		return sum == S;
	int& ret = mem[idx][sum];
	if (ret != -1)
		return ret;
	ret = (2LL * dp(idx + 1, sum)) % MOD;
	ret = (ret + dp(idx + 1, sum + A[idx])) % MOD;
	return ret;
}

int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	cin >> N >> S;

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

	memset(mem, -1, sizeof(mem));

	cout << dp(1, 0) << '\n';


	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


Measured memory_bytes: 39116
n, k, q = map(int, input().split())
a = sorted([int(input()) for _ in range(q)])
point = [k-q for _ in range(n)]
for i in range(q):
    point[a[i]-1] += 1
for j in  point:
    if j > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 11812
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from itertools import combinations # (string,3) 3回
#from collections import deque
#import collections.defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    A = readInts() # n-1人いるようです
    B = [0] * (n)
    for i in range(n-1):
        a = A[i] - 1
        B[a] += 1
    print(*B,sep='\n')
if __name__ == '__main__':
  main()


Measured memory_bytes: 32372
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()

ans = 0
for i in range(1, N+1):
	m = N//i
	ans += m*(m+1)*i//2
print(int(ans))


Measured memory_bytes: 63392
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    if (p[i] < p[i+1] and p[i+1] < p[i+2]) or (p[i] > p[i+1] and p[i+1] > p[i+2]) :
        ans += 1
print(ans)

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

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

	a.erase(unique(a.begin(),a.end()), a.end());
	
	bool isFirst=true;
	for(auto &&ai: a){
		if(!isFirst) cout<<" ";
		cout<<ai;
		isFirst &= false;
	}
	cout<<endl;
  return 0;
}



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

int main(){
    int n,k,ans=0;
    cin >> n >> k;
    for(int i=1;i<=n;i+=2){
        ans++;
    }
    if(ans>=k){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N,H,W,A,B;
  int cnt=0;
  cin>>N>>H>>W;
  for(int i=0;i<N;i++){
    cin>>A>>B;
    if(A>=H && B>=W) cnt++;
  }
  cout<<cnt;
}


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

int main() {
  string S;
  cin >> S;
  sort(S.begin(),S.end());
  if(S.at(0)==S.at(1) && S.at(2)==S.at(3) && S.at(0) != S.at(2)) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 3596
N = int(input())
A_list = [int(item) for item in input().split()]

all_sum = sum(A_list)

F_sum_list = [A_list[0]]

for j in range(1,N):
    F_sum_list.append(F_sum_list[-1] + A_list[j])

delta_list = [abs(all_sum - 2* i) for i in F_sum_list]

print(min(delta_list))

Measured memory_bytes: 29352
#include <stdio.h>
#include <math.h>

int main (void)
{
    long long N, P;
    long long ans;

    scanf("%lld %lld", &N, &P);

    ans = (long long)powl((long double)P, 1 / (long double)N);

    for (;;) {
        if (P % (long long)powl((long double)ans, (long double)N) == 0) {
            printf("%lld\n", ans);
            return 0;
        }
        ans--;
    }
}


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

using namespace std;
using ll = long long;

int main()
{
  double N, K; cin >> N >> K;

  double ans = 0;
  for (int i = 1; i <= N; ++i) {
    int l = ceil(log2(K/i));

    if (l > 0) {
      ans += (1/N) * pow((1/2.), l);
    } else {
      ans += (1/N);
    }
  }

  printf("%.12f\n", ans);
}

Measured memory_bytes: 384
def main():
    import fractions
    n = int(input())
    inlis = []
    for _ in range(n):
        a = int(input())
        inlis.append(a)
    
    ans = inlis[0]
    for i in range(1, n):
        ans = ans * inlis[i] // fractions.gcd(ans, inlis[i])

    print(ans)

    
    
if __name__ == "__main__":
    main()


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

typedef struct pair{
  int x,y;
}point;

int compare_int(const void *a,const void *b){
  return (*(point*)a).x > (*(point*)b).x;
}

int main(void){
  int N,M;
  scanf("%d%d",&N,&M);

  point A[N];
  for(int i = 0;i < N;i++) scanf("%d%d",&A[i].x,&A[i].y);

  qsort(A,N,sizeof(point),compare_int);

  int cnt = 0;
  long long money = 0;  
  for(int i = 0;;i++){
    if(cnt+A[i].y < M){
      cnt += A[i].y;
      money += (long long)A[i].y*A[i].x;
    }else{
      money += (long long )(M-cnt)*A[i].x;
      break;
    }
  }

  printf("%lld\n",money);

  return 0;
}

Measured memory_bytes: 1788
import java.util.*;
public class Main {
  public static void main(String[] args){
    Map<String, Integer> m = new HashMap<>();
    m.put("SUN", 7);
    m.put("MON", 6);
    m.put("TUE", 5);
    m.put("WED", 4);
    m.put("THU", 3);
    m.put("FRI", 2);
    m.put("SAT", 1);


    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    System.out.println(m.get(a));

    sc.close();
  }
}


Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
priority_queue <int> q;
const int N = 3e5+5;
int a[N];
int main(){
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	if(s=="AAA"||s=="BBB") cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int N, K;
    cin >> N >> K;

    vector<int> l(N);
    rep(i, N) cin >> l[i];

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

    int ans = 0;
    rep(i, K) {
        ans += l[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7, INF = 1e9 + 100; 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int x, y;
	cin >> x >> y;
	if(x * 500 >= y){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
}

Measured memory_bytes: 256
s_ori = input()
s = [int(c) for c in s_ori]
n = len(s) - 1
for bit in range(2**n):
    total = s[0]
    for i in range(n):
        if (1 << i) & bit:
            total += s[i+1]
        else:
            total -= s[i+1]
    if total == 7:
        break

ans = ''
for i in range(n):
    if bit & (1<<i):
        ans += s_ori[i] + '+'
    else:
        ans += s_ori[i] + '-'

ans += s_ori[-1] + '=7'

print(ans)

Measured memory_bytes: 38384
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 4e18;

// bellman-ford法
struct edge { int to, cost; };

void bellman_ford(int s, const vector<vector<edge>> &G, vector<ll> &d) {
    const int V = G.size();
    d = vector<ll>(V, LLINF);
    d[s] = 0;
    bool update = true;
    int i = 0;
    while (update)
    {
        update = false;
        for (int j = 0; j < V; j++)
        {
            for (edge e : G[j])
            {
                if (d[j] != -LLINF && d[j] != LLINF && d[j] + e.cost < d[e.to]) {
                    d[e.to] = d[j] + e.cost;
                    if (i == V - 1) {
                        d[e.to] = -LLINF;
                    }
                    update = true;
                }
                else if (d[j] == -LLINF && d[e.to] != -LLINF) {
                    d[e.to] = -LLINF;
                    update = true;
                }
            }
        }
        if (i < V - 1) i++;
    }
}

int main() {
    int n, m, p; cin >> n >> m >> p;
    vector<vector<edge>> G(n);
    vector<ll> dist(n);
    REP(i, m) {
        int a, b, c; cin >> a >> b >> c;
        a--; b--; c -= p;
        c *= -1;
        G[a].push_back({b,c});
    }
    bellman_ford(0, G, dist);
    if (dist[n - 1] == -LLINF) cout << -1 << endl;
    else cout << max(0LL, -dist[n - 1]) << endl;
    getchar(); getchar();
}

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

int main(){
 	int N,P,mi(200000),ans(0);
  	cin >> N;
  	for(int i = 0 ; i < N ; i++){
     	cin >> P;
      	if(mi >= P){
          	ans ++;
          	mi = P;
        }
   	}
  	cout << ans << endl;
}

Measured memory_bytes: 256
import functools


if __name__ == "__main__":
    n = int(input())

    xs = list(map(int, input().split()))
    ys = list(map(int, input().split()))

    diffs = list(map(lambda x, y: abs(x - y), xs, ys))

    manhattan_distance = functools.reduce(lambda acc, diff: acc + diff, diffs, 0.0)
    euclidean_distance = (functools.reduce(lambda acc, diff: acc + (diff ** 2), diffs, 0.0))**(1 / 2)
    minkowski_distance_p3 = (functools.reduce(lambda acc, diff: acc + (diff ** 3), diffs, 0.0))**(1 / 3)
    chebyshev_distance = max(diffs)

    print(manhattan_distance)
    print(euclidean_distance)
    print(minkowski_distance_p3)
    print(chebyshev_distance)



Measured memory_bytes: 6320
import math
denom = int(1e9+7)

def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p


def combi2(n,k,p,f,pow_fun):
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=fact_mod[n]
  b=fact_mod[k]
  c=fact_mod[n-k]
  return (a*pow_fun[b]*pow_fun[c])%p


N, K = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort(reverse = True)

fact_mod = [1]
current = 1
for i in range(1,N+1):
    current = (current * i) % denom
    fact_mod.append(current)

pow_fun = {}
for i in fact_mod:
    pow_fun[i]=power_func(i,denom-2,denom)

max_tot = 0
min_tot = 0
for i in range(N-K+1):
    max_tot += (A[i] * combi2(N-i-1, K-1, denom, fact_mod,pow_fun)) % denom
    min_tot += (A[N-i-1] * combi2(N-i-1, K-1, denom, fact_mod,pow_fun)) % denom
    
print((max_tot - min_tot)%denom)

Measured memory_bytes: 24564
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ch() getchar()
#define pc(x) putchar(x)
template<typename T>inline void read(T&x){
	int f;char c;
	for(f=1,c=ch();c<'0'||c>'9';c=ch())if(c=='-')f=-f;
	for(x=0;c<='9'&&c>='0';c=ch())x=x*10+(c&15);x*=f;
}
template<typename T>inline void write(T x){
	static char q[64];int cnt=0;
	if(!x)pc('0');if(x<0)pc('-'),x=-x;
	while(x)q[cnt++]=x%10+'0',x/=10;
	while(cnt--)pc(q[cnt]);
}
const int maxn=1000006;
int pri[maxn],vis[maxn],mn[maxn],cnt[maxn],ans[maxn];
int main(){
	int n;read(n);ans[1]=1;
	for(int i=2,tot=0;i<=n;++i){
		if(!vis[i])pri[++tot]=i,mn[i]=1,cnt[i]=1,ans[i]=2;
		for(int j=1;j<=tot;++j){
			int t=pri[j]*i;if(t>n)break;
			vis[t]=true;if(i%pri[j]==0){mn[t]=mn[i];cnt[t]=cnt[i]+1;ans[t]=ans[mn[t]]*(cnt[t]+1);break;}
			mn[t]=i;cnt[t]=1;ans[t]=ans[i]*2;
		}
	}
	long long Ans=0;
	for(int i=1;i<n;++i)
		Ans+=ans[n-i];
	write(Ans),pc('\n');
	return 0;
}


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

using namespace std;

const int mod = 1e9+7;

int fact(int n){
    int ans=1;
    for(int i=1;i<=n;i++){
        ans=(1LL*ans*i)%mod;
    }
    return ans;
}

int main(){
    int n,m;
    cin >> n >> m;
    if(abs(n-m)>1){
        cout << 0 << endl;
        return 0;
    }
    int ans = (1LL*fact(n)*fact(m))%mod;
    if(n==m){
        ans=(ans*2)%mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int M=1e6+50;
int n,ch[M][26],cnt,num[M][26],pp[M],l;char s[M];bool fl[M],hav[26];LL ans;
void insert(){
    int p=0;
    for(int i=1;i<=l;i++){
        int c=s[i]-'a';
        if(!ch[p][c])ch[p][c]=++cnt;
        p=ch[p][c];pp[i]=p;
    }
    fl[p]=1;memset(hav,0,sizeof(hav));
    for(int i=l;i;i--){
        hav[s[i]-'a']=1;
        for(int j=0;j<26;j++)
            if(hav[j])num[pp[i-1]][j]++;
    }
}
void dfs(int x){
    for(int i=0,y;i<26;i++)
        if((y=ch[x][i])){
            dfs(y);//cout<<num[x][i]<<" ";
            if(fl[y])ans+=num[x][i]-1;
        }
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%s",s+1);l=strlen(s+1);
        reverse(s+1,s+l+1);
        insert();
    }
    dfs(0);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 254616