akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)
int main() { 
  string s,t;cin >> s >> t;
  int len = s.length();
  rep(i,len){
    if(s==t){
      cout << "Yes" << endl;
      return 0;
    }else{
      s = s[len-1] + s.substr(0,len-1);
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

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

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

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string S; cin >> S;
    lint res;
    if (S == "SUN") res = 7;
    else if (S == "MON") res = 6;
    else if (S == "TUE") res = 5;
    else if (S == "WED") res = 4;
    else if (S == "THU") res = 3;
    else if (S == "FRI") res = 2;
    else res = 1;
    cout << res << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    long long cnt1 = 0, cnt2 = 0, ans = 0;
    for (long long i = 0; i < s.size(); i++) {
        cnt1 = 0;
        cnt2 = 0;
        if (s[i] == '>') {
            while (s[i] == '>' && i < s.size()) {
                i++;
                cnt1++;
            }
            i--;
            ans += cnt1 * (cnt1 + 1) / 2;
        }
        if (s[i] == '<') {
            while (s[i] == '<' && i < s.size()) {
                i++;
                cnt1++;
            }
            while (s[i] == '>' && i < s.size()) {
                i++;
                cnt2++;
            }
            i--;
            long long a = max(cnt1, cnt2), b = min(cnt1, cnt2);
            ans += a * (a + 1) / 2 + b * (b - 1) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){
    long long int a, b, c, k, ans = 0;
    cin >> a >> b >> c >> k;
    
    for(int i=0;i<3;i++){
        if(i==0 && k>0){
            if(a <= k) ans += a;
            else ans += k;
            k = k-a;
        }
        if(i==1 && k>0) {
            k = k-b;
        }
        if(i==2 && k>0) {
            if( c <= k) ans -= c;
            else ans -= k;
            k = k-c;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


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


int main() {
	vector <int> A(5);
	int k;
	string answer = "Yay!";
	for (int i = 0; i < 5; i++) {
		cin >> A.at(i);
	}
	cin >> k;
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			if (-k > A.at(j) - A.at(i) || A.at(j) - A.at(i) > k) {
				answer = ":(";
				goto ans;
			}
		}
	}
ans:
	cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

int N;
std::string S, prv;

int main()
{
    std::cin >> N >> S;
    int cntS = 0;

    rep( i, N )
    {
        if( S[i] == ')' )
        {
            if( cntS == 0 )
                prv += '(';
            else
                --cntS;
        }
        if( S[i] == '(' )
            ++cntS;
    }

    std::cout << prv+S+std::string(cntS, ')') << std::endl;

    return 0;
}

Measured memory_bytes: 256
<?php
$trump = array();
$hold = array();
for ($i = 1; $i <= 52; $i++) {
	if ($i <= 13) $trump[] = "S ".$i;
	if ($i >= 14 && $i <= 26) $trump[] = "H ".($i-13);
	if ($i >= 27 && $i <= 39) $trump[] = "C ".($i-26);
	if ($i >= 40 && $i <= 52) $trump[] = "D ".($i-39);
}
$n = trim(fgets(STDIN));
for ($j = 0; $j < $n; $j++) {
	$hold[] = trim(fgets(STDIN));
}
$shortage = array_diff($trump, $hold);
if (!$shortage) echo "";
else echo implode("\n", $shortage)."\n";

Measured memory_bytes: 15236
import sys
n = int(input())
h = list(map(int, input().split()))[::-1]

for i in range(1,n):
    if h[i] > h[i-1] + 1:
        print("No")
        sys.exit()
    elif h[i] == h[i-1] + 1:
        h[i] -= 1




print("Yes")

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> V(N);
    REP(i,N){
        int v;
        cin >> v;
        V[i] = v;
    }

    sort(V.begin(), V.end());

    double ans = 0;
    ans = (V[0] + V[1]) / 2.0;
    for(int i = 2; i < N; i++){
        ans = (ans + V[i]) / 2.0;
    }

    printf("%.20lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
// #include "prettyprint.hpp"

using namespace std;

typedef long long ll;


#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, n) for(ll i=n; i>=0; i--)
#define reps(i, s, e) for(ll i=s; i<e; i++)
#define all(x) x.begin(),x.end()

int main(){

	int x,y,z;

	cin >> x >> y >> z;

	cout << z  << " " << x << " " <<  y << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);

  int mx = 0, cnt = 0;
  for (int i = 0; i < N; i++) if (H.at(i) >= mx) cnt++, mx = H.at(i);

  cout << cnt << "\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;
typedef long long ll;
ll ans;

int main()
{
    ll n,m;
    while(~scanf("%lld%lld",&n,&m))
    {
        if(n==1 && m==1) ans=1;
        else if(n==1) ans=m-2;
        else if(m==1) ans=n-2;
        else ans=(n-2)*(m-2);
        printf("%lld\n",ans);
    }

    return 0;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
     int n,r;
     cin >> n >> r;
     if(n>=10) cout << r << endl;
     else cout << r+100*(10-n) << endl;
}

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

int main() {
    long long n;
    std::cin >> n;
    std::map<long long, long long, std::greater<>> m;
    for (int i = 0; i < n; i++) {
        long long t;
        std::cin >> t;
        m[t]++;
    }
    std::vector<long long> v;
    for (auto& el : m) {
        if (el.second >= 4) {
            v.push_back(el.first);
            v.push_back(el.first);
        } else if (el.second >= 2) {
            v.push_back(el.first);
        }

        if (v.size() >= 2) break;
    }
    std::cout << (v.size() >= 2 ? v[0] * v[1] : 0) << std::endl;
    return 0;
}

Measured memory_bytes: 6528
#listの要素をキー、その出現数を値として持つディクショナリを返す
def count(list):
    dict = {}
    for i in range(len(list)):
        dict[list[i]] = dict.get(list[i], 0) + 1
    return dict

n = int(input())
s = []
for _ in range(n):
    s.append(input())

dic = count(s)
lst = sorted(dic.items(), key=lambda x: x[1], reverse=True)
value_max = lst[0][1]
output = []

for name in lst:
    if name[1] == value_max:
        output.append(name[0])
    else:
        break

output.sort()
print(*output,sep="\n")

Measured memory_bytes: 150308
#include<iostream>
using namespace std;
int main(){
        long long N;
        long long count[5]={};
        string S;
        cin >> N;
        for(int i=0; i<N; i++){
                cin >> S;
                if(S[0]=='M')
                        count[0]++;
                else if(S[0]=='A')
                        count[1]++;
                else if(S[0]=='R')
                        count[2]++;
                else if(S[0]=='C')
                        count[3]++;
                else if(S[0]=='H')
                        count[4]++;
        }
        long long sum=count[0]*count[1]*count[2]+count[0]*count[1]*count[3]+count[0]*count[1]*count[4]+count[0]*count[2]*count[3]+count[0]*count[2]*count[4]+count[0]*count[3]*count[4]+count[1]*count[2]*count[3]+count[1]*count[2]*count[4]+count[1]*count[3]*count[4]+count[2]*count[3]*count[4];
        cout << sum << endl;
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
double pi = 3.1415926535898;
int main()
{
      ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
      double n;
      cin >> n;
      n = 2*n*pi;
      cout << n << endl;
      return 0;
}


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

int main() {
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')cout << "vowel" << endl;
	else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node  {
    int key;           //データ
    Node *next, *prev; //前の要素と次の要素のポインタ
};

Node *nil;

/*引数として与えられたキーを持つノードのポインタを返す*/
Node* listSearch(int key) {
    Node *cur = nil->next;  //番兵の次から順に辿る
    while ( cur != nil && cur->key != key ) {
        cur = cur->next;
    }//curのキーが一致したらループを抜ける
    return cur;
}

/*番兵を作る関数*/
void init() {   
    nil = (Node *)malloc(sizeof(Node));  //メモリを確保
    nil->next = nil;
    nil->prev = nil;
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while (1) {
        if ( cur == nil ) break;
        if ( isf++ > 0 ) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

/*指定されたノードtを削除する関数*/
void deleteNode(Node *t) {
    if ( t == nil ) return;
    t->prev->next = t->next;  //削除手順１
    t->next->prev = t->prev;  //削除手順２
    free(t);  //メモリを開放する
}

/*先頭のノード(番兵の次のノード)を削除する関数*/
void deleteFirst() {
    deleteNode(nil->next);
}

/*末尾のノード(番兵の前のノード)を削除する関数*/
void deleteLast() {
    deleteNode(nil->prev);
}

/*キーが一致するノードを削除する関数*/
void deleteKey(int key) {
    deleteNode(listSearch(key));
}

/*ノードを生成する関数*/
void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));  //メモリを確保
    x->key = key;  //データの数値
    x->next = nil->next;  //挿入手順１
    nil->next->prev = x;  //挿入手順２
    nil->next = x;        //挿入手順３
    x->prev = nil;        //挿入手順４
}


int main() {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for ( i = 0; i < n; i++ ) {
        scanf("%s%d", com, &key);
        //入力がinsert
        if ( com[0] == 'i' && com[5] == 't') { 
          insert(key); np++; size++; }  //ノードを追加
        //入力がdelete~
        else if ( com[0] == 'd' ) {
            if ( strlen(com) > 6 ) {
                //入力がdeleteFirst
                if ( com[6] == 'F' ) {
                  deleteFirst();}//先頭ノード削除
                //入力がdeleteLast
                else if ( com[6] == 'L' ) {
                  deleteLast();}}//末尾ノード削除
                //入力がdelete
            else {
                deleteKey(key); nd++;}  //指定されたノードを削除
            size--;
        }
    }

    printList();

    return 0;
}



Measured memory_bytes: 34008
from bisect import bisect_left
n=int(input())
a=list(map(int,input().split()))
a.sort()
if(a[0]>=0):
    print(sum(a[1:])-a[0])
    ans=a[0]
    for i in a[1:n-1]:
        print(ans,i)
        ans-=i
    print(a[-1],ans)
elif(a[-1]<=0):
    print(a[-1]-sum(a[:n-1]))
    ans=a[-1]
    for i in a[:n-1]:
        print(ans,i)
        ans-=i
else:
    print(sum([abs(i) for i in a]))
    b=bisect_left(a,0)
    ans=a[0]
    tmp=a[-1]
    for i in a[b:n-1]:
        print(ans,i)
        ans-=i
    for i in a[1:b]:
        print(tmp,i)
        tmp-=i
    print(tmp,ans)

Measured memory_bytes: 62748
number = int(input())
scaffolds = list(map(int, input().split()))
costs = [ 0 for i in range(number)]

for i in range(len(costs)):
    hight = scaffolds[i]

    i_1 = -1
    if 0 <= i - 1:
        min_v = costs[i - 1]
        hight_1 = scaffolds[i - 1]
        i_1 = min_v + abs(hight_1 - hight)

    i_2 = -1
    if 0 <= i - 2:
        min_v = costs[i - 2]
        hight_2 = scaffolds[i - 2]
        i_2 = min_v + abs(hight_2 - hight)
    if i_1 < 0 and i_2 < 0:
        costs[i] = 0
    elif i_1 < 0:   
        costs[i] = i_2
    elif i_2 < 0:
        costs[i] = i_1
    else:
        costs[i] = min(i_1, i_2)  
    
    
print(costs[number - 1])

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

int main(){
     int N;
     string s;
     int r = 0; //red_flag
  
     cin >> N;
     cin >> s;
              
     for(auto c:s){
       if(c=='R') r++;
       else r--;
     }
    
    if(r>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import sys, math
from functools import lru_cache
from collections import defaultdict
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, D = mi()
    X, Y = i2(N)
    print(sum(1 for i in range(N) if X[i]**2+Y[i]**2 <= D**2))

if __name__ == '__main__':
    main()

Measured memory_bytes: 63116
#include<bits/stdc++.h>
#define inf 1<<30
using namespace std;

class State{
public:
  int h,w,leg,cost;
  State(int a,int b,int c,int d):h(a),w(b),leg(c),cost(d){}
  bool operator<(State s)const{
    return s.cost<cost;
  }
};

int w,h;
char s[100][100];
int dp[100][100][2]={};
//            a                    b
int x[2][9]={{1,1,1,1,1,2,2,2,3},{-1,-1,-1,-1,-1,-2,-2,-2,-3}};
int y[2][9]={{-2,-1,0,1,2,-1,0,1,0},{-2,-1,0,1,2,-1,0,1,0}};

bool in(int a,int b){
  if(a<0 || b<0 || h<=a || w<=b)return false;
  return true;
}

int main()
{
  while(1){
    cin>>w>>h;
    if(w+h==0)break;
    priority_queue<State> pq;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>s[i][j];
	dp[i][j][0]=inf;
	dp[i][j][1]=inf;
	if(s[i][j]=='S'){
	  pq.push(State(i,j,0,0));
	  pq.push(State(i,j,1,0));
	  dp[i][j][0]=0;
	  dp[i][j][1]=0;
	}
	if(s[i][j]=='T')s[i][j]='0';
      }
    }

    int ans=inf;
    while(!pq.empty()){
      State u=pq.top();
      pq.pop();

      if(dp[u.h][u.w][u.leg]<u.cost)continue;

      if(s[u.h][u.w]=='0'){
	ans=min(ans,u.cost);
	continue;
      }

      for(int k=0;k<9;k++){
	int a=u.h+y[u.leg][k],b=u.w+x[u.leg][k],c=(u.leg+1)%2;
	if(!in(a,b))continue;
	if(s[a][b]=='X' || s[a][b]=='S')continue;
	if((u.cost+(s[a][b]-'0'))<dp[a][b][c]){
	  dp[a][b][c]=u.cost+(s[a][b]-'0');
	  pq.push(State(a,b,c,dp[a][b][c]));
	}
      }
    }
    if(ans!=inf)cout<<ans<<endl;
    else cout<<-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1272
/* HARE KRSNA HARE KRSNA KRSNA KRSNA HARE HARE
    HARE RAMA HARE RAMA RAMA RAMA HARE HARE  */

#include <bits/stdc++.h>
using namespace std;

#define nl "\n"
#define ff first
#define ss second
#define pp pop_back
#define pf pop_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define b_s binary_search
#define all(x) x.begin(),x.end()
#define test ll t; cin>>t; while(t--)
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define rloop(i,s,n) for(ll i=s;i>=n;i--)
#define fill(a,value) memset(a,value,sizeof(a))

#define debug2(a)  for(auto x : a)  cout<<x<<" ";  cout<<nl;
#define debug4(a)  for(auto x : a)  cout<<x.ff<<" "<<x.ss<<nl;
#define debug1(a,n) loop(i,0,n)  cout<<a[i]<<" ";  cout<<nl;
#define debug3(a,n,m)  loop(i,0,n){ loop(j,0,m)	cout<<a[i][j]<<" ";	cout<<nl; }

typedef long long ll;
typedef long double ld;

typedef stack<ll> sll;
typedef queue<ll> qll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<ll, pll> ppll;
typedef vector<vector<ll>> vvll;
typedef priority_queue<ll> pqll;

const ll mod = 1000000007;	//998244353;
const ld pi =  acos((ld) - 1);	//3.1415926535;

ll num_generator()		{   return rand() % 1000;	}
void array_generator(ll a[], ll n)		{   loop(i, 0, n)	a[i] = rand() % 100;	}

void solve()
{
	ll n;	cin >> n;
	ll a[n];	loop(i, 0, n)		cin >> a[i];
	sort(a, a + n, greater<>());
	ll ans = 0, m = 0, i = 0;
	// debug1(a, n);
	while (m <= n && i < n)
	{
		m++;
		if (m > n)		break;
		if (m == 1)	ans += 0;
		else if (m == 2)
		{
			ans += a[i];
			i++;
		}
		else
		{
			ans += a[i];
			m++;
			if (m > n)		break;
			ans += a[i];
			i++;
		}
		// cout << m << " " << ans << nl;
	}
	cout << ans << nl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();
	return 0;
}

Measured memory_bytes: 5268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var p = Console.ReadLine().ToInt();
		for(int i = 1; i <= 9; i++)
			for(int j = 1; j <= 9; j++)
			{
				if(p==i*j)
				{
					Console.WriteLine("Yes");
					return;
				}
			}
		Console.WriteLine("No");
	}
	

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



Measured memory_bytes: 13140
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n;cin >> n;ll mod = 1000000007,sum = 1;
	rep(i, n) {
		sum *= (i + 1);
		sum %= mod;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

ll arr[100000];
int main() {
    cin >> N >> K;
    rep(i, N){
        cin >> arr[i];
    }

    ll ans = 0;
    rep(i, N-1){
        if(arr[i]+arr[i+1] > K){
            ans += arr[i]+arr[i+1] - K;
            arr[i+1] = K - arr[i];
        }
    }
    if(arr[N-1] > K) ans += arr[N-1] - K;
    cout << ans;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e8+1;
int main()
{
    FASTINOUT;
    string s;
    cin>>s;
    if (s[0]==s[1]&&s[1]==s[2] ||(s[1]==s[2]&&s[2]==s[3]))
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#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.at(i);
    }
    int count = 0;
    for(int i = 0;i < n - 2;i++) {
        if((a.at(i) < a.at(i + 1) && a.at(i + 1) < a.at(i + 2)) || (a.at(i) > a.at(i + 1) && a.at(i + 1) > a.at(i + 2))) {
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
def solve():
    dp = [0] * N
    L = max(l)
    R = min(r)
    if L <= R:
        i = list(range(L,R+1))
        ans = len(i)
    else:
        ans = 0
    print(ans)

if __name__ == "__main__":
    N,M = list(map(int, input().split()))
#    LR = [list(map(int, input().split())) for _ in range(M)]
    l,r = [0]*M, [0]*M
    for c in range(M):
        tmp = list(map(int, input().split()))
        l[c] = tmp[0]
        r[c] = tmp[1]
    solve()  


Measured memory_bytes: 18652
import java.io.CharArrayReader;
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int s = 0;
        ArrayList<Integer> arr = new ArrayList<Integer>();
        for(int i=0;i<n;i++)arr.add(sc.nextInt());
        Collections.sort(arr);
        for(int j=0;j<k;j++)s += arr.get(j);
        System.out.println(s);
    }
}


Measured memory_bytes: 38844
import java.io.*;
import java.util.Arrays;

class Main{
	public static void main(String[] args)throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String str = br.readLine();
	String[] line = str.split(" ");

	int a = Integer.parseInt(line[0]);
	int b = Integer.parseInt(line[1]);
	int c = Integer.parseInt(line[2]);

	int retu[] = { a , b , c};

	Arrays.sort(retu);

	System.out.println(retu[0] + " " + retu[1] + " " + retu[2]);
}
}

Measured memory_bytes: 24384
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        int N = int.Parse(s);
        int digitSum = 0;
        for (int i = 0; i < s.Length; i++)
            digitSum += s[i] - '0';
        Console.WriteLine(N % digitSum == 0 ? "Yes" : "No");
    }
}


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

using namespace std;

int main()
{
	string c1, c2;
	cin >> c1 >> c2;

	reverse(c1.begin(), c1.end());
	if (c1 == c2)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}


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

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

    int64_t ans = 0;
    for (int64_t k = K; k <= N+1; ++k) {
        ans += (N-k+1)*k+1;
        ans %= 1000000007;
    }
    cout << ans << "\n";
}


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

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

	cin >> k;

	string ans;
	for (int i = 0; i < k; i++) {
		ans += "ACL";
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s; int k;
	cin >> s >> k;
	set<string> cand;
	for (int i = 0; i < s.size(); i++)
	{
		string t = "";
		for (int j = 0; j < 5 && i + j < s.size(); j++)
		{
			t += s[i+j];
			cand.insert(t);
		}
	}

	auto it = cand.begin();
	for (int i = 1; i < k; i++)
	{
		it++;
	}

	cout << *it << endl;
	return 0;
}


Measured memory_bytes: 1664
result = {}
while True:
    num, accepted = map(int, raw_input().split(','))
    if num == 0 and accepted == 0: 
        break
    else:
        result[num] = accepted

rank = 1
accepted = 0      
for k, v in sorted(result.items(), key=lambda x: x[1], reverse=True):
    if accepted > v:
        rank += 1
    result[k] = rank
    accepted = v
        
while True:
    try:
        num = int(raw_input())
        print result[num]
    except EOFError:
        break

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#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, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const int MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

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

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    if(a%b == 0) return b;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}



int main(){
    ll X, Y, A, B, C;
    cin  >> X >> Y >> A  >> B >> C;
    priority_queue<ll> qa, qb, qc;
    ll ans = 0;
    REP(i, A){ll a; cin >> a; qa.push(-a); ans +=a;}
    REP(i, B){ll a; cin >> a; qb.push(-a);ans +=a;}
    REP(i, C){ll a; cin >> a; qc.push(a);}
    ll a = 0,b = 0;
    while(qa.size() != X ) { a -= qa.top();qa.pop();}
    while(qb.size() != Y) {b -= qb.top(); qb.pop();}
    ans -= a + b;
    for(int i = 0; i < X + Y; ++i){
        if(qc.empty()) break;
        if(qa.empty() and !qb.empty()){
            if(-qb.top() < qc.top()){ans += qb.top() + qc.top(); qb.pop(); qc.pop();}
            continue;
        }
        if(qb.empty() and !qa.empty()){
            if(-qa.top() < qc.top()){ans += qa.top() + qc.top(); qa.pop(); qc.pop();}
            continue;
        }
        if(qa.empty() and qb.empty()) break;

        if(-qa.top() <= -qb.top() and -qa.top() < qc.top()){ans += qa.top() + qc.top(); qa.pop(); qc.pop(); continue;} 
        if(-qb.top() < -qa.top() and -qb.top() < qc.top()){ans += qb.top() + qc.top(); qb.pop(); qc.pop();continue;} 
    }
    cout << ans ;
    return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int m,d; cin >> m >> d;
    int ans = 0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            int d1 = j%10;
            int d10 = j / 10;

            if(d1 >= 2 and d10 >= 2 and d1 * d10 == i){
                ans++;
            }
        }
    }
    cout << ans << endl;
}


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

int main(){
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double mov = ((m/5.0)*15.0)/6.0;
    double gradeM = (m/5.0/12.0)*360.0;
    double gradeH = ((h/12.0) * 360.0) + mov;
    double ang = abs(gradeM - gradeH);
    ang*=acos(-1)/180.0;
    double rta = sqrt(a*a + b*b - (2.0*a*b*cos(ang)));
    cout<<fixed<<setprecision(9)<<rta<<endl;
}


Measured memory_bytes: 4156
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

const ll MOD = 1e9+7;

void dfs(Vvec<int>& graph, Vvec<ll>& dp, int tmp, int from)
{
    dp[tmp][0] = 1;
    dp[tmp][1] = 1;
    if(from != -1 && graph[tmp].size() == 1){
        return;
    }

    for(auto& to: graph[tmp]){
        if(to != from){
            dfs(graph, dp, to, tmp);
            dp[tmp][0] *= dp[to][1];
            dp[tmp][1] *= (dp[to][0] + dp[to][1])%MOD;
            dp[tmp][0] %= MOD;
            dp[tmp][1] %= MOD;
        }
    }
}

int main()
{
    int N;
    cin >> N;
    Vvec<int> graph(N);
    for(int i=0; i<N-1; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    Vvec<ll> dp(N, vector<ll>(2));
    dfs(graph, dp, 0, -1);

    cout << (dp[0][0] + dp[0][1])%MOD << endl;
}

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<string,int> mp;
    int n;cin>>n;
    rep(i,n){
        string ss;
        cin>>ss;
        mp[ss]+=1;
    }
    int maxi=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        int k=itr->second;
        if(k>maxi)maxi=k;
    }
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        if(itr->second==maxi){
            cout<<(itr->first)<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 23808
#include<cstdio>
#include<algorithm>
int main(){
    int n,s[100],sum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&s[i]);
        sum+=s[i];
    }
    if(sum%10!=0){
        printf("%d",sum);
        return 0;
    }
    std::sort(s,s+n);
    int k=0;
    while(k<n&&s[k]%10==0)k++;
    if(k==n)printf("0");
    else printf("%d",sum-s[k]);
    return 0;
}

Measured memory_bytes: 128
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>=0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main () {
	VI a(6),b(5);
	int n = 6;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) b[a[i]]++;

	sort(b.rbegin(),b.rend());

	//rep(i, 4) cout << b[i] << endl;

	if (b[0] == 2&& b[1] == 2 && b[2] == 1 && b[3] == 1) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	
	return 0;
}


 

Measured memory_bytes: 256
X,K,D = map(int,input().split())
X = abs(X)
ans = 0

if (X // D) >= K:
    ans = X - (K * D)
elif (X // D) % 2 == 0:
    if K % 2 == 0:
        ans = X % D
    else:
        ans = abs((X % D) - D)
else:
    if K % 2 ==1:
        ans = X % D
    else:
        ans = abs((X % D) - D)

print(ans)

Measured memory_bytes: 9180
a, b, c = map(int, input().split())

li = [a, b, c]
li.sort()

ans = 0
for i in range(2):
    cnt = (li[2] - li[i]) // 2
    li[i] += 2 * cnt
    ans += cnt

ans += li.count(max(li)) % 3
print(ans)


Measured memory_bytes: 3060
#B

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
List = []
for i in range(N):
    List.append(V[i]-C[i])
List.sort(reverse=True)
total = 0
for i in List:
    if i > 0:
        total += i
print(total)

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

typedef long long ll;

int n;
string s;

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

    int blue = 0;
    int red = 0;
    for (int i =0 ; i< n; i++){
        if (s[i] == 'R' ){
            red++;
        }  else{
            blue++;
        }
    }

    if (red > blue){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    double ret = 0.0;
    multimap<double, pair<int, int> > mm;
    for(int i=0; i<n; ++i){
        int w, v;
        cin >> w >> v;
        if(w > 0){
            if(v > 0)
                mm.insert(make_pair(-v/(double)w, make_pair(w, v)));
        }else{
            wSum -= w;
            ret += v;
            if(v < 0)
                mm.insert(make_pair(-v/(double)w, make_pair(-w, -v)));
        }
    }

    while(!mm.empty()){
        int w = mm.begin()->second.first;
        int v = mm.begin()->second.second;
        mm.erase(mm.begin());

        if(w <= wSum){
            wSum -= w;
            ret += v;
        }else{
            ret += (double)v * wSum / w;
            wSum = 0;
        }
    }

    printf("%.10f\n", ret);
    return 0;
}

Measured memory_bytes: 1520
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ara[5],i,x,y,n;
    for(i=0;i<5;i++)
        cin>>ara[i];
    int sum=0,mx=0,p=0,q=0;
    for(i=0;i<5;i++)
    {
        x=ceil(ara[i]/10.0);
        y=(x*10);
        sum+=y;
        if((y-ara[i])>mx)
        {
            mx=y-ara[i];
            p=ara[i];
            q=y;
        }
    }
    cout<<(sum-q+p)<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 998244353;
const int IMAX = 100000;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	constexpr unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
	int comb(int A, int B) {
		return ll(fac[A]) * ifac[B] % mod * ifac[A - B] % mod;
	}
} f;

int A[100001], B[100001];
char S[300010];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N;
	scanf("%d ", &N);

	fread(S, 1, N * 3, stdin);

	int r = 0, g = 0, b = 0;
	int rg = 0, gb = 0, br = 0;
	rep(i, 3 * N) {
		if (S[i] == 'R') {
			if (gb) B[gb--]++;
			else if (g) A[g--]++, rg++;
			else if (b) A[b--]++, br++;
			else r++;
		}
		else if (S[i] == 'G') {
			if (br) B[br--]++;
			else if (b) A[b--]++, gb++;
			else if (r) A[r--]++, rg++;
			else g++;
		}
		else {
			if (rg) B[rg--]++;
			else if (r) A[r--]++, br++;
			else if (g) A[g--]++, gb++;
			else b++;
		}
	}

	ll kotae = f.fac[N];
	for (int i = N; i >= 1; i--) {
		if (A[i]) {
			kotae = kotae * f.fac[i] % mod;
			while (i >= 1) {
				if (A[i] > 1) {
					kotae = kotae * modpow(i, A[i] - 1) % mod;
				}
				i--;
			}
			break;
		}
	}
	for (int i = N; i >= 1; i--) {
		if (B[i]) {
			kotae = kotae * f.fac[i] % mod;
			while (i >= 1) {
				if (B[i] > 1) {
					kotae = kotae * modpow(i, B[i] - 1) % mod;
				}
				i--;
			}
			break;
		}
	}

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


	Would you please return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
using namespace std; typedef long long ll; const int INF=100; typedef pair<int,int> P;

int main() {
  ll n,k; cin>>n>>k;
  cout<<min(min(n-(n/k-1)/k,n-n/k*k),(n/k+1)*k-n)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int i,j,k;
    int N,D;
    int X[20][20] = {0};
  
    scanf("%d %d",&N,&D);
    
    for(i = 0;i < N;i++){
        for(j = 0;j < D-1;j++){
            scanf("%d\n",&X[i][j]);
        }
        scanf("%d",&X[i][j]);
    }
    
    int n,total,answer = 0;
    float f;
    for(i = 0;i < N-1;i++){
        for(j = i+1;j < N;j++){
            total = 0;
            for(k = 0;k < D;k++){
                total += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            f = sqrt(total);
            n = f;
            if((f - n) == 0){
                answer++;
            }
        }
    }
    printf("%d\n",answer);
    
    return 0;
}



Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
  
    int i,j,n,m,r,sum=0;
    int a[100][100],b[100];

    scanf("%d %d",&i,&j);
    
    
    for (n=0; n<i; n++) {
        for(m=0; m<j ; m++){
            scanf("%d ",&r);
            a[n][m]=r;
         }
    }
    for (n=0; n<j; n++) {
        scanf("%d",&r);
        b[n]=r;
    }
    for (n=0; n<i; n++) {
        for(m=0; m<j;m++){
            sum +=a[n][m]*b[m];
        }
        printf("%d\n",sum);
        sum=0;
    }
    return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
int main (){
    int N,X,min,ans,sum=0;
    vector<int> v(N);
    cin >> N >> X >> v.at(0);
    min = v.at(0);
    sum = v.at(0);
    

    for(int i=1;i<N;i++){
        cin >> v.at(i);
        sum += v.at(i);
        if(v.at(i)<min){
            min = v.at(i);
        }
    }
   

    ans = (X-sum)/min + N;
    cout << ans << endl;
}

Measured memory_bytes: 16640
n = int(input())

i=0
taro=0
hanako=0
while i<n:
  t, h=input().split()
  
  if t>h:
    taro+=3
  
  elif t==h:
    taro+=1
    hanako+=1
  
  elif t<h:
    hanako+=3

  i+=1
  
print(str(taro)+' '+str(hanako))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
// priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 

ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}

 
ll n,m,num,sum,a,b,c,d,e,h,r,l,q;
ll k;
ll ans;
ll x[500005], y[500005], z[500005], w[500005];
char s[500005];
ll dp[30][2005];

int main(){
    cin >> n >> m;
    c3_init();
    for(ll i=0;i<m;i++){
        cin >> x[i];
    }
    dp[0][0] = 1;
    for(ll i=1;i<=m;i++){
        for(ll j=0;j<=n;j++){
            // dp[i][j]がどうなるか？
            for(ll k=0;k<=j;k++){
                ll inc = j - k;
                if(x[i-1] < inc)continue;
                ll co = c3(n - k, inc) * c3(n - inc, x[i-1] - inc);
                co %= mod;
                dp[i][j] += dp[i-1][k] * co;
                dp[i][j] %= mod;
            }
        }
    }
    p(dp[m][n]);
    return 0;
}
 











Measured memory_bytes: 39808
#include<stdio.h>
int main(void)
{
  int a,b,c,d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  while (1)
  {
    c = c - b;
    if (c <= 0){
      printf("Yes");
      return 0;}
    a = a - d;
    if (a <= 0){
      printf("No");
      return 0;}
  }
  return 0;
}

Measured memory_bytes: 1692
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}


// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
};

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}



// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll a,b;
    cin >> a >> b;
    print(lcm(a, b));
}

//int n;
//cin >> n;
//vector<int> test(n);
//cins(all(test));
//array_output(all(test));

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

int main(){
	int n, i, j, maxp, minp;
	cin >> n;
	int a[n];
	for(i = 0; i < n; i++){
		cin >> a[i];
	}
	
	maxp = a[1]-a[0];
	minp = a[0];
	for(i = 1; i < n; i++){
		maxp = max(maxp, a[i]-minp);
		minp = min(minp, a[i]);
	}
	
	cout << maxp << endl;
	return 0;
}

Measured memory_bytes: 1940