akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std ;

int main()
{
  string S ;
  cin >> S ;
  
  if(S == "Sunny")
    cout << "Cloudy" << endl ;
  else if(S == "Cloudy")
    cout << "Rainy" << endl ;
  else if(S == "Rainy")
    cout << "Sunny" << endl ;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a,b,c,cmp,cmpp,m,h,w,x,y,sum=0;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true,graph[100][100];

int dfs(int now,int n,bool* visited){
    bool allvisited=true;
    rep(i,n){
        if(!visited[i]){
            allvisited=false;
        }
    }
    
    if(allvisited){
        return 1;
    }
    
   int pos=0;
    
    rep(i,n){
        if(!graph[now][i]){
            continue;
        }
        if(visited[i]){
            continue;
        }
        visited[i]=true;
        pos+=dfs(i,n,visited);
        visited[i]=false;
    }
    return pos;
}

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

       cin >> n >> m;
       rep(i,m){
           cin >> a >> b;
           graph[a-1][b-1]=true;
           graph[b-1][a-1]=true;
       }
       bool visited[100];
       
       rep(i,n){
           visited[i]=false;
       }
       visited[0]=true;
       Cout(dfs(0,n,visited));
       
return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public static void main(String[] args) throws Exception {
		int[] array = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		
		int x = array[0];
		int y = array[1];
		
		System.out.println(resolve(x, y));
	}
	
	public static int resolve(int x, int y){
		int large = Math.max(x, y);
		int small = Math.min(x, y);
		
		int mod = large % small;
		int answer = 0;
		if(mod != 0){
			answer = resolve(small, mod);
		}else{
			answer = small;
		}
		
		return answer;
	}
	
}



Measured memory_bytes: 31048
#include <iostream>
#include <stdio.h>
#include <utility>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
typedef pair<int,int> p;
int tx,ty,sx,sy;
double r,rx,ry;
bool cir(double x,double y){
	return (x-rx)*(x-rx)+(y-ry)*(y-ry)<r*r;
}
int main()
{
    int n,m;
	while(cin>>n&&n){
		pair<int,p> wall[100];//<r,<x,y>>
		for(int i=0;i<n;i++)cin>>wall[i].second.first>>wall[i].second.second>>wall[i].first;
		cin>>m;
		for(int i=0;i<m;i++){
			string ans="Danger";
			cin>>tx>>ty>>sx>>sy;
			double a,b,c;
			if(tx!=sx&&ty!=sy){
				a=(double)(ty-sy)/(tx-sx);
				b=(double)-1;
				c=ty-(double)a*tx;
			}else if(tx==sx){
				a=1;
				b=0;
				c=-tx;
			}else if(ty==sy){
				a=0;
				b=1;
				c=-ty;
			}
			double bo=sqrt(a*a+b*b);
			double d=(a*a+b*b)/(a*b);
			for(int j=0;j<n;j++){
				r=(double)wall[j].first;
				rx=(double)wall[j].second.first;
				ry=(double)wall[j].second.second;
				double shi=abs(a*rx+b*ry+c);
				double res=shi/bo;
				//printf("a:%.3f b:%.3f c:%.3f shi:%.3f bo:%.3f res:%.3f\n",a,b,c,shi,bo,res);
				if(r<res)continue;
				double px,py;//?????????????????????????????¨?????????
				if((a!=0)&&(b!=0)){
					px=(b/a*rx-ry-c/b)/d;
					py=-a/b*px-c/b;
				}else if(a!=0){//y????????????
					px=-c;
					py=ry;
				}else if(b!=0){//x????????????
					py=-c;
					px=rx;
				}
				if(cir((double)sx,(double)sy)&&cir((double)tx,(double)ty)){
					continue;
				}else if(cir((double)sx,(double)sy)!=cir((double)tx,(double)ty)||
					((double)min(sx,tx)<px&&px<(double)max(sx,tx))||((double)min(sy,ty)<py&&py<(double)max(sy,ty))){
					ans="Safe";
					break;
				}
			}
			cout<<ans<<endl;
		}
	}
    return 0;
}

Measured memory_bytes: 1200
import math


def combinations_count(n, r):
    return math.factorial(n)//(math.factorial(n-r) * math.factorial(r))


n,a,b = map(int, input().split())
v = list(map(int, input().split()))

v.sort()
v.reverse()

print(sum(v[:a])/a)

c = v.count(v[a-1])
d = v[:a].count(v[a-1])

if v[0]!=v[a-1]:
    print(combinations_count(c,d))
else:
    ans = 0
    lim = min(c,b)
    for i in range(a,lim+1):
        ans += combinations_count(c,i)
    print(ans)



Measured memory_bytes: 3064
program main;
var
    yr : integer;
    target, bal : int64;
begin
    yr := 0;
    bal := 100;
    readln(target);
    while bal < target do begin
        bal := trunc(bal*1.01);
        yr := yr + 1;
        if bal >= target
            then writeln(yr);;
    end;
end.


Measured memory_bytes: 1380
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <stdio.h>
#include <vector>
#include <stack>
#include <iomanip>
const int SIZE = 1000005;

using namespace std;
int n,k;
int a[1005];


int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int ans = 0;
    for(int i=0;i<k;i++)
        ans += a[i];
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3560
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class atA {
public:
    void solve(istream& in, ostream& out) {
        int N, C, K;
        in >> N >> C >> K;
        vector<int> T(N);
        for (int i = 0; i < N; ++i) {
            in >> T[i];
        }
        sort(T.begin(), T.end());
        
        int startTime = 0, num = 0, res = 0;
        for (int t : T) {
            if (t - startTime > K) {
                res += num > 0;
                num = 0;
            }
            if (num == 0) {
                startTime = t;
            }
            ++num;
            if (num == C) {
                ++res;
                num = 0;
            }
        }
        res += num > 0;
        out << res << "\n";
    }
};


int main() {
	std::ios::sync_with_stdio(false);

	atA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

int main()
{
	string s = "keyence";
	string sr;
	cin>>sr;
	for(int i=0;i<sr.length();i++){
		for(int j=0;j<sr.length();j++){
			string ss = sr;
			ss.erase(i,j);;
			if(ss==s){
				cout<<"YES";
				return 0;
			}
		}
	}
	cout<<"NO";
} 


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

using namespace std;

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

uint64_t calc_dist(uint64_t N, const map<uint64_t, set<uint64_t>> &edges, uint64_t start, vector<uint64_t> &dist)
{
  queue<pair<uint64_t, uint64_t>> q;
  q.emplace(start, 0);

  while (!q.empty()) {
    pair<uint64_t, uint64_t> p = q.front(); q.pop();

    dist[p.first] = p.second;

    for (const uint64_t &v : edges.at(p.first)) {
      if (dist[v] < p.second + 1) { continue; }

      q.emplace(v, p.second + 1);
    }
  }

  return 0;
}

int main()
{
  uint64_t N, start_u, start_v;
  cin >> N >> start_u >> start_v;
  --start_u; --start_v;

  map<uint64_t, set<uint64_t>> edges;
  N_TIMES(n, N) { edges[n] = set<uint64_t>(); }
  N_TIMES(n, N - 1) {
    uint64_t a, b;
    cin >> a >> b;

    edges[a - 1].insert(b - 1);
    edges[b - 1].insert(a - 1);
  }
  
  if (edges[start_u].size() == 1) {
    uint64_t v = *edges[start_u].begin();
    if (v == start_v) {
      cout << 0 << endl;
      return 0;
    }
  }

  set<uint64_t> leaves;
  N_TIMES (n, N) {
    if (n == start_v) { continue; }
    if (edges[n].size() == 1) { leaves.insert(n); }
  }

  vector<uint64_t> P(N, -1), Q(N, -1);
  calc_dist(N, edges, start_u, P);
  calc_dist(N, edges, start_v, Q);
  
  uint64_t farest = 0;
  for (uint64_t leaf : leaves) {
    if (P[leaf] < Q[leaf]) {
      if (farest <= Q[leaf]) {
        farest = Q[leaf];
      }
    }
  }

  cout << (farest - 1) << endl;

  return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}

int main() {
  int n; cin >> n;
  vector<double> a(n); REP(i, n) cin >> a[i];
  sort(all(a));
  long long tmp = a[n - 1];
  ll tmp2 = 0;
  ll diff = pow(10,9);
  ll ans = 0;
  REP(i, n - 1) {
    if(diff > abs(tmp / 2.0 - a[i])) {
      diff = abs(tmp / 2.0 - a[i]);
      tmp2 = a[i];
    }
  }
  cout << tmp << " " << tmp2 << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#define rep(i,n) for(i=0;i<(n);i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main(){
    int N, X, T;
    cin >> N >> X >> T;
    int times = (N + X - 1) / X;
    int ans = times * T;
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include<stdio.h>
	#include<string.h>
	int main()
	{
		int tc;
		char input[105];
		scanf("%d",&tc);
		scanf("%s",input);
		int len = strlen(input);
		for(int i = 0;i<len;i++)
		{
			if(tc >= len)
			{
				printf("%s",input);
				break;
			}
			else if(i < tc)
			{
			printf("%c",input[i]);
			}
			else{
				printf("...\n");
				break;
			}
		}
		
		return 0;
	}

Measured memory_bytes: 2140
#include<cstdio>
#define MIN(a,b) ((a)<(b)?(a):(b))
long long a,b,c,d,e,f;
signed main()
{
	return scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e),f=MIN(a<<2,MIN(c,b<<1)),printf("%lld\n",f<<1<=d?f*e:f*(e&1)+(e>>1)*d),0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())

mod = 10**9 + 7

no = [False] * (n+1)

for _ in range(m):
    a = int(input())
    no[a] = True
    
dp = [0] * (n+1)
dp[0] = 1

for i in range(n):
    if (no[i]):
        dp[i] = 0
    
    if i + 1 <= n:
        dp[i+1] += dp[i]
    if i + 2 <= n:
        dp[i+2] += dp[i]
        
print(dp[n] % mod)


Measured memory_bytes: 463476
#include<iostream>
#include<cmath>
using namespace std;
long long H;
long long res=0;
long long dep=0;

void dfs(long long h){
    if(h==1){
        res += pow(2,dep);

    }
    else{
        res += pow(2,dep);
        dep++;
        dfs(h/2);
    }
}

int main(){
    cin >> H;
    dfs(H);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	long int N, i, sum;
	sum= 0;

	scanf("%ld", &N);
	for (i = 1; i <= N; i++) {
		if (((i % 3) != 0) && ((i % 5 )!= 0)) {
			sum += i;
		}
	}
	printf("%ld", sum);

	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    if(s.at(s.size()-1)=='s')
    {
        cout << s << "es" << endl;
    }
    else
    {
        cout << s << "s" << endl;
    }
}

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

namespace A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = RInt();
            int h = RInt();
            int w = RInt();
            Console.WriteLine((n - h + 1) * (n - w + 1));
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}


Measured memory_bytes: 13140
class Node():

    def __init__(self, node_id, left, right):
        self.node_id = node_id
        self.parent = -1
        self.sibling = -1
        self.left = left
        self.right = right
        self.degree = 0
        self.depth = 0
        self.height = 0
        self.type = "leaf"

    def set_attr(self, node_id, parent, sibling, depth):
        if node_id == -1:
            return -1
        self.parent = parent
        self.sibling = sibling
        self.depth = depth
        self.degree = (self.left != -1) + (self.right != -1)
        if self.degree:
            self.type = "internal node"
        if self.parent == -1:
            self.type = "root"
        self.height = max(tree[self.left].set_attr(self.left, self.node_id, self.right, self.depth + 1),
                          tree[self.right].set_attr(self.right, self.node_id, self.left, self.depth + 1)) +1
        return self.height

n = int(input())
tree = [0] * n
root = set(range(n))

for i in range(n):
    node_id, left, right = map(int, input().split())
    tree[node_id] = Node(node_id, left, right)
    root -= set([left, right])

root_id = root.pop()
tree[root_id].set_attr(root_id, -1, -1, 0)

for node in tree:
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(
        node.node_id, node.parent, node.sibling, node.degree, node.depth, node.height, node.type))

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

long long prime[100001],pprime[100001];

void prime_search(){
  bool judge[100001];
  for(int i=0;i<=100000;i++){
    judge[i]=true;
  }
  for(int i=2;i<=100000;i++){
    if(judge[i]==true){
      prime[i]++;
      for(int j=i*2;j<=100000;j+=i){
        judge[j]=false;
      }
    }
  }
  for(int i=2;i<=100000;i++){
    if(prime[i]==1){
      if(prime[(i+1)/2]==1){
        pprime[i]++;
      }
    }
  }
  for(int i=2;i<=100000;i++){
    pprime[i]+=pprime[i-1];
  }
}

int main(){
  prime_search();
  long long q,l,r;
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> l >> r;
    cout << pprime[r]-pprime[l-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {

    map<int, int> problems;
    int n;
    int m;
    int wrongCount = 0;
    int acceptCount = 0;

    cin >> n >> m;

    for(int i = 0; i < m; ++i) {
        int problem;
        string result;
        
        cin >> problem >> result;

        if(result == "AC") {
            if(problems.find(problem) != problems.end() && problems[problem] != -1)
                wrongCount += problems[problem];

            if(problems[problem] != -1)
                acceptCount++;

            problems[problem] = -1;
        
        }
        else {
            
            if(problems.find(problem) == problems.end())
                problems[problem] = 0;

            if(problems[problem] != -1)
                problems[problem]++;
        }

    }

    cout << acceptCount << " " << wrongCount;

    return 0;

}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        
        while(N--){
            string S;cin>>S;
            string T;
            
            int now=0,cnt=0;
            
            while(now<S.size()){
                if(S[now]=='0'){
                    now++;
                    continue;
                }
                cnt=0;
                while(S[now]==S[now+cnt]) cnt++;
                int rcnt=cnt;
                if(S[now]-'0'==1){
                    cnt%=5;
                    if(cnt==1) T+='.';
                    if(cnt==2) T+=',';
                    if(cnt==3) T+='!';
                    if(cnt==4) T+='?';
                    if(cnt==0) T+=' ';
                }
                if(S[now]-'0'==2){
                    cnt%=3;
                    if(cnt==1) T+='a';
                    if(cnt==2) T+='b';
                    if(cnt==0) T+='c';
                }
                if(S[now]-'0'==3){
                    cnt%=3;
                    if(cnt==1) T+='d';
                    if(cnt==2) T+='e';
                    if(cnt==0) T+='f';
                }
                if(S[now]-'0'==4){
                    cnt%=3;
                    if(cnt==1) T+='g';
                    if(cnt==2) T+='h';
                    if(cnt==0) T+='i';
                }
                if(S[now]-'0'==5){
                    cnt%=3;
                    if(cnt==1) T+='j';
                    if(cnt==2) T+='k';
                    if(cnt==0) T+='l';
                }
                if(S[now]-'0'==6){
                    cnt%=3;
                    if(cnt==1) T+='m';
                    if(cnt==2) T+='n';
                    if(cnt==0) T+='o';
                }
                if(S[now]-'0'==7){
                    cnt%=4;
                    if(cnt==1) T+='p';
                    if(cnt==2) T+='q';
                    if(cnt==3) T+='r';
                    if(cnt==0) T+='s';
                }
                if(S[now]-'0'==8){
                    cnt%=3;
                    if(cnt==1) T+='t';
                    if(cnt==2) T+='u';
                    if(cnt==0) T+='v';
                }
                if(S[now]-'0'==9){
                    cnt%=4;
                    if(cnt==1) T+='w';
                    if(cnt==2) T+='x';
                    if(cnt==3) T+='y';
                    if(cnt==0) T+='z';
                }
                now=now+rcnt+1;
            }
            
            cout<<T<<endl;
        }
        break;
    }
}



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

// https://github.com/atcoder-live/library/blob/master/mint.cpp
const std::int64_t mod = 1000000007;
struct mint {
    std::int64_t x; // typedef long long ll;
    mint(std::int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(std::int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
std::istream& operator>>(std::istream& is, const mint& a) { return is >> a.x;}
std::ostream& operator<<(std::ostream& os, const mint& a) { return os << a.x;}


int main() {
    ll N; cin >> N;
    vector<ll> A(N); for (int i = 0; i < N; ++i) cin >> A[i];
    mint x = 0;
    mint ans = 0;
    for (int i = N - 2; i >= 0; --i) {
        int j = i + 1;
        x += mint(A[j]);
        ans += (mint(A[i]) * x);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4840
def main():
    n, q = map(int, input().split())
    St = [list() for _ in range(n)]

    for _ in range(q):
        para = [int(a) for a in input().split()]

        if para[0] == 0:
            St[para[1]].append(para[2])
        if para[0] == 1:
            if len(St[para[1]]) != 0:
                print(St[para[1]][-1])
        if para[0] == 2:
            if len(St[para[1]]) != 0:
                St[para[1]].pop()
main()



Measured memory_bytes: 13696
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define ll long long
using namespace std;
const int N=2e5;
struct edge{int fr,to,w;}a[N],sta[N];
int n,m,val[N],fa[N];
int siz[N],cnt,top,ans;
ll sum[N];
int cmp(const edge&A,const edge&B) {return A.w<B.w;}
int find(int x) {return fa[x]==x?x:find(fa[x]);}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&val[i]);
		fa[i]=i,siz[i]=1,sum[i]=val[i];
	}
	for(int i=1,x,y,w;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&w);
		a[++cnt]=(edge){x,y,w};
	}
	sort(a+1,a+cnt+1,cmp);

	for(int i=1;i<=cnt;i++)
	{
		int x=a[i].fr,y=a[i].to;
		x=find(x);y=find(y);
		if(x==y) continue;
		if(siz[x]>siz[y]) swap(x,y);
		sta[++top]=(edge){x,y,a[i].w};
		fa[x]=y;siz[y]+=siz[x];sum[y]+=sum[x];
	}
	for(int i=top;i>=1;i--)
	{
		int x=sta[i].fr,y=sta[i].to;
		ll v=sum[find(y)],val=sta[i].w;
		if(v<val) fa[x]=x,siz[y]-=siz[x],sum[y]-=sum[x];
	}
	for(int i=1;i<=m;i++)
	{
		int x=a[i].fr,y=a[i].to;
		if(find(x)!=find(y)) ans++;
		else if(a[i].w>sum[find(x)]) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 7552
def main():
    a,b,c,d = map(int, input().split())
    max = -1000000000000000000000000000
    for x in [a, b]:
        for y in [c, d]:
            if x*y > max:
                max = x*y
    print(max)
        
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 9168
#include <iostream>

int main()
{
    int time;
    std::cin >> time;
    std::cout << time / 3600 << ":" << (time - (time / 3600) * 3600) / 60 << ":" << (time - (time / 3600)*3600) % 60 << std::endl;
    return 0;
}


Measured memory_bytes: 3096
S=input()
n=S.count('N')
s=S.count('S')
e=S.count('E')
w=S.count('W')
if (n >= 1 and s >= 1) or (n == 0 and s == 0):
  if (e >= 1 and w >= 1) or (e == 0 and w == 0):
    print('Yes')
    exit()
print('No')

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

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

    ll a[n];
    rep(i, n){
        cin >> a[i];
        a[i] -= i + 1;
    }

    sort(a, a + n);

    ll b;
    if(n % 2 == 1){
        b = a[n / 2];
    }else{
        b = (a[n / 2 - 1] + a[n / 2]) / 2;
    }

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

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


Measured memory_bytes: 1792
//                                                  '-.-'
   //                                         ()      __.'.__
   //                                      .-:--:-.  |_______|
   //                               ()      \____/    \=====/
   //                               /\      {====}     )___(
   //                    (\=,      //\      )__(     /_____\
   //    __    |'-'-'|  //  .\    (    )    /____\     |   |
   //   /  \   |_____| (( \_  \    )__(      |  |      |   |
   //   \__/    |===|   ))  `\_)  /____\     |  |      |   |
   //  /____\   |   |  (/     \    |  |      |  |      |   |
   //   |  |    |   |   | _.-'|    |  |      |  |      |   |
   //   |__|    )___(    )___(    /____\    /____\    /_____\
   //  (====)  (=====)  (=====)  (======)  (======)  (=======)
   //  }===={  }====={  }====={  }======{  }======{  }======={
   // (______)(_______)(_______)(________)(________)(_________)
   //
   // Credits :- Joan G. Stark
   //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
   //|                      AUTHOR - _P_VATSAL_                                     |
   //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
#include<bits/stdc++.h>
#include <iomanip>
#include <string>
using namespace std;
//************
//***CODER***
//PRANAV VATSAL
//************
typedef long long ll;
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define f first
#define s second
typedef vector<pli> vpli;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(v) v.begin(),v.end() 
#define fr(i,n) for(i=0;i<n;i++)
#define frr(i,a,b) for(i=a;i<b;i++)
using ld=long double;
lli INF=1e18;
int inf=1e6;
#define endl '\n'


void solve()
{
	lli n;
	cin>>n;
	lli a[n+1];
	lli b[n+1];
	lli c[n+1];
	lli dp[n+1][4];

	lli i;
	fr(i,n)
	{
		cin>>a[i+1]>>b[i+1]>>c[i+1];
	}

	dp[0][1]=0;
	dp[0][2]=0;
	dp[0][3]=0;
	//dp[i][j] is max happiness on day i if dayi has jth activity
	frr(i,1,n+1)
	{
		dp[i][1]=max(dp[i-1][2]+a[i],dp[i-1][3]+a[i]);
		dp[i][2]=max(dp[i-1][1]+b[i],dp[i-1][3]+b[i]);
		dp[i][3]=max(dp[i-1][1]+c[i],dp[i-1][2]+c[i]);
	}
	lli ans =max({dp[n][1],dp[n][2],dp[n][3]});
	cout<<ans;
}


int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t;
  //cin>>t;
  //while(t--)
    solve();
  return 0;
}


Measured memory_bytes: 9020
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,k,a[55];
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<k;i++){
		ans+=a[n-i-1];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
var s,t:string[30];
    i,c,x,a,b:longint;
 begin
  readln(s);
  for i:=1 to length(s) do
   if(s[i]='+')or(s[i]='-')then 
    c:=i;
  for i:=1 to c-2 do 
   t:=t+s[i];
  val(t,a);
  t:='';
  for i:=c+2 to length(s) do 
   t:=t+s[i];
  val(t,b);
  if s[c]='+'then writeln(a+b)
             else writeln(a-b);
 end.

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

/*Node treeMinimum(Node);
  Node treeMaximum(Node);*/
Node treeSearch(Node,int);
/*Node treeSuccessor(Node);
Node treeDelete(Node);*/
void insert(int);
void inorder(Node);
void preorder(Node);




int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t;
      t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
	else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      /* treeDelete(treeSearch(root, x));*/
    }
  }

  return 0;
}

/*Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


} */

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key)
    return u;
    if(k<u->key) return treeSearch(u->left,k);
    else  return treeSearch(u->right,k);


}

/*Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



  }*/

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key)
      x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)
    root=z;
  else if(z->key < y->key)
    y->left=z;
  else
    y->right=z;
 




}

void inorder(Node u){
  if(u->left==NIL&&u->right==NIL){
    printf(" %d",u->key);
    return;
  }
   if(u->left!=NIL)
  inorder(u->left);
  printf(" %d",u->key);
  if(u->right!=NIL)
  inorder(u->right);

}
void preorder(Node u){
  if(u->left==NIL&&u->right==NIL){
    printf(" %d",u->key);
      return;
  }
  printf(" %d",u->key);
  if(u->left!=NIL)
  preorder(u->left);
  if(u->right!=NIL)
  preorder(u->right);

}



Measured memory_bytes: 20520
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

const int MOD = 1e9+7;

int modpow(ll x, int n) {
    ll ret = 1;
    while (n) {
        if (n%2)
            ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return ret;
}

int main(void) {
    int i, n;
    scanf("%d",&n);
    map<int,int> mp;
    REP (i,n) {
        int a;
        scanf("%d",&a);
        mp[a]++;
    }
    int x = n - 1;
    while (x > 0) {
        if (mp[x] != 2) {
            puts("0");
            return 0;
        }
        x = x - 2;
    }
    if (n % 2 == 1 && mp[0] != 1) {
        puts("0");
        return 0;
    }
    printf("%d\n",modpow(2,n/2));
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <map>
// #include <algorithm>
// #include <set>
// #include <cmath>
// #include <string>
 
#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
 

map<int, int> factorize(int n) {
    map<int, int> ret;
    for (int i = 2; i <= n; i++) {
        bool first = true;
        while (n % i == 0) {
            if (first) {
                ret[i] = 1;
                first = false;
            } else {
                ret[i] += 1;
            }
            n /= i;
        }
    }
    return ret;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, const map<T1, T2>& m) {
    os << "{";
    for (const auto x : m) {
        os << x.first << ":" << x.second << " ";
    }
    os << "}";
    return os;
}

map<int, int> merge(const map<int, int>& m1, const map<int, int>& m2) {
    map<int, int> ret = m1;
    for (auto item : m2) {
        auto iter = ret.find(item.first);
        if (iter == ret.end()) {
            ret[item.first] = item.second;
        } else {
            ret[item.first] += item.second;
        }
    }
    return ret;
}

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
 
    map<int, int> all_factors;
    for (int i = 2; i <= N; i++) {
        auto factors = factorize(i);
        // cout << i << endl;
        // cout << factors << endl;
        all_factors = merge(all_factors, factors);
    }
    // cout << all_factors << endl;

    ull ans = 1;
    for (auto item : all_factors) {
        ans = (ans * (item.second + 1)) % MOD;
    }
    cout << ans << endl;
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main() {
    int n ;
    cin >> n ;
    ll tot = 0 ;
    for(int i = 1; i <= n; i++){
        ll f = n/i ;
        tot += i*(1+f)*f/2 ;
    } 
    cout << tot << endl ;
}


Measured memory_bytes: 3616
import sys

o, e = sys.stdin.read().split()

def main():
    s = [None] * (len(o) + len(e))
    s[::2] = list(o)
    s[1::2] = list(e)
    return ''.join(s)

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define endl '\n'
//#define int ll
using namespace std;
const ll inf = 1ll<<60;
const int iinf = 2147483647;
const ll mod = 1e9+7;
 
signed main (){
   ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   int n; cin>>n;
   string str; cin>>str;
   REP(i,SZ(str)){
   	str[i]=((str[i]-'A')+n)%26+'A';
   }
   cout<<str<<endl;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    if(s[0]==s[1] && s[1]==s[2]) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    string s; cin >> s;
    for (int i = 0; i < 4; i++) {
        bool b[n];
        b[0] = ((i&1) != 0);
        b[1] = ((i&2) != 0);
        for (int j = 2; j < n; j++)
            b[j] = b[j-1] ^ b[j-2] ^ (s[j-1] == 'o');
        if ((s[0] == 'o') ^ b[0] ^ b[n-1] ^ b[1]) continue;
        if ((s[n-1] == 'o') ^ b[n-1] ^ b[n-2] ^ b[0]) continue;
        for (int j = 0; j < n; j++) cout << (b[j]?'S':'W');
        cout << endl;
        return 0;
    }
    cout << -1 << endl;
}


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

int main()
{
    int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0;
    is_prime[1] = 0;
    for (int i = 2; i < MAX; i++)
    {
        if (!is_prime[i]) continue;
        for (int j = i * 2; j < MAX; j += i) is_prime[j] = 0;
    }

    vector<int> a(MAX, 0);
    for (int i = 0; i < MAX; i++)
    {
        if (i % 2 == 0) continue;
        if (is_prime[i] && is_prime[(i + 1) / 2]) a[i] = 1;
    }

    vector<int> s(MAX + 1, 0);
    for (int i = 0; i < MAX; i++) s[i + 1] = s[i] + a[i];

    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        int l, r;
        cin >> l >> r;
        r++;

        cout << s[r] - s[l] << endl;
    }

    return 0;
}


Measured memory_bytes: 4420
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i,j,k;
  int n;
  cin>>n;
  rep(i,n){
    string ord,s;
    cin>>ord;
    cin>>s;
    int len=s.size();
    for(j=ord.size()-1;j>=0;j--){
      if(ord[j]=='C'){
    string tmp="";
    tmp.push_back(s[0]);
    s.erase(s.begin());
    s+=tmp;
      }else if(ord[j]=='J'){
    string tmp="";
    tmp.push_back(s[len-1]);
    s.erase(s.end()-1);
    s=tmp+s;
      }else if(ord[j]=='A'){
    reverse(all(s));
      }else if(ord[j]=='E'){
    rep(k,len/2)
      swap(s[k],s[(len+1)/2+k]);
      }else if(ord[j]=='M'){
    rep(k,len)
      if(s[k]<='8' && s[k]>='0')s[k]++;
      else if(s[k]=='9')s[k]='0';
      }else{
    rep(k,len)
      if(s[k]<='9' && s[k]>'0')s[k]--;
      else if(s[k]=='0')s[k]='9';
      }
    }
    cout<<s<<endl;
  }
}

Measured memory_bytes: 3088
#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);
  }
  sort(a.begin(),a.end());
  int flag ;
  int kotae;
  for( int i = a.at(1) ; i > 0 ; --i ){
    flag = 0;
    for(int j = 0 ; j < n ;j++){
      if ( a.at(j) % i != 0){
        flag += 1;
      }
      if(flag == 2){
        break;
      }
      if( j == n-1 ){
        if( flag == 1 || flag == 0){
        kotae = i;
        }
      }
    }
    if ( kotae == i ){
      break;
    }
  }
  cout << kotae << endl;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
const ll INF = 1e15;

ll diff(ll a, ll b, ll c) { return max(a, max(b, c)) - min(a, min(b, c)); }

int main() {
  ll h, w;
  cin >> h >> w;

  ll ans = INF;

  FOR(i, 1, w) {
    ll a = i * h;
    ll b = h * ((w - i) / 2);
    ll c = h * (w - i - (w - i) / 2);
    ans = min(ans, diff(a, b, c));
  }

  FOR(i, 1, h) {
    ll a = i * w;
    ll b = w * ((h - i) / 2);
    ll c = w * (h - i - (h - i) / 2);
    ans = min(ans, diff(a, b, c));
  }

  FOR(i, 1, w) {
    ll a = i * h;
    ll b = (w - i) * (h / 2);
    ll c = (w - i) * (h - h / 2);
    ans = min(ans, diff(a, b, c));
  }

  FOR(i, 1, h) {
    ll a = i * w;
    ll b = (h - i) * (w / 2);
    ll c = (h - i) * (w - w / 2);
    ans = min(ans, diff(a, b, c));
  }

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

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

using namespace std;

#define MODULE 1000000007
#define MP make_pair

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9
const int MAXN = 100001;

/*struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];*/


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

//-----Template---------
int n;
int a[100001];
int main(){
	ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
	scanf("%d",&n);
	for (int i = 0; i < n; i++) {
		scanf("%d",&a[i]);
	}
	LL counter=a[0]-1;
	int maxNum=1;
	for (int i = 1; i < n; i++) {
		if(a[i]<(maxNum+2)) {//maxnum+1が割れる数の最小値，maxnum+2より小さいとあまりが出ない
			chmax(maxNum,a[i]);
			continue;
		}

		if(a[i]%(maxNum+1)!=0) { //a[i]が割れる数の最小の倍数なら
			counter+=a[i]/(maxNum+1);
			chmax(maxNum,a[i]%(maxNum+1));
		}else{
			a[i]-=maxNum+2;
			counter+=a[i]/(maxNum+1) +1;
			chmax(maxNum,a[i]%(maxNum+1));
		}
	}
	cout<<counter<<endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,a[100000];
  cin>>n;
  for(int i=0;i<n;i++){
	cin>>a[i];
  }
  sort(a,a+n);
  cout<<a[n-1]-a[0]<<"\n";
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; cin >> N;
	if(N == 1){
		cout << "Hello World" << endl;
		
	}else if(N == 2){
		int A, B; cin >> A >> B;
		cout << A+B << endl;
	}


	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define float long double
#define M 1000000007



int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t=1;
	int n;cin>>n;int k;cin>>k;
	int a[n];int c=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int a1[n],a2[n];
	memset(a1,0,sizeof(a1));
	memset(a2,0,sizeof(a2));
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			if(a[i]>a[j]){
				a1[i]++;
			}
		}
		for(int j=0;j<n;j++){
			if(a[i]>a[j]){
				a2[i]++;
			}
		}

	}
	for(int i=0;i<n;i++){
		c+=(k*a1[i])%M+(a2[i]*(((k*(k-1))/2)%M))%M;
		c=c%M;
	}


	cout<<c<<endl;





	


	return 0;
}

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

using namespace std;

int main() {
    string c0, c1;
    cin >> c0 >> c1;
    cout << (c0[0] == c1[2] && c0[1] == c1[1] && c0[2] == c1[0] ? "YES" : "NO") << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
typedef long long ll;
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    ll n;cin >> n;
    vector<ll> hen(n);
    REP(i,n)cin >> hen[i];
    ll ans=0;
    REP(i,n)FOR(j,i+1,n)FOR(k,j+1,n){
        if(hen[i] == hen[j] || hen[j] == hen[k] || hen[k] == hen[i])continue;
        ll x=hen[i]+hen[j];
        ll y=hen[j]+hen[k];
        ll z=hen[k]+hen[i];
        if(hen[i]<y && hen[j] < z && hen[k]<x)ans++;
    }
    cout << ans << endl;
}//https://atcoder.jp/contests/abc175/tasks/abc175_b

Measured memory_bytes: 3592
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = [0]*n
for i in range(n):
    a[i] = INT()

ans = 0
for i in range(n-1):
    ans += a[i]//2
    a[i] %= 2
    if a[i] == 1 and a[i+1] >= 1:
        ans += 1
        a[i] -= 1
        a[i+1] -= 1
ans += a[n-1]//2
print(ans)

Measured memory_bytes: 14160
N, M = map(int, input().split())
ans = 0

def fac(n):
    ans = 1
    for i in range(1, n+1):
        ans *= i
        ans %= (10**9+7)
    return ans

if abs(N-M) >= 2:
    ans = 0
else:
    if N == M:
        ans = fac(N) * fac(M) * 2 % (10**9+7)
    else:
        ans = fac(N) * fac(M) % (10**9 + 7)

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n;  cin >> n;
    vector<ll> l(n);
    rep(i,0,n) cin >> l[i];
    ll ans = 0;
    sort(ALL(l));

    for(ll i=n-1;i>=2;i--){
        for(ll j=i-1;j>=1;j--){
            for(ll k=j-1;k>=0;k--){
                if(l[i] < l[j]+l[k]) ans++;
            }
        }
    }

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


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
typedef long long LL;
int main()
{   LL l,j,k,i;
	int n;
	scanf("%d",&n);
	if ( n == 0) printf("2\n");
	else if ( n == 1 ) printf("1\n");
	else if(n >= 2)
	{
		for(i=2,j=2,k=1;i<=n;i++)
		{   
			l=k+j;
			j=k;
			k=l;
			}
   	printf("%lld\n",l);}
	return 0;
}

Measured memory_bytes: 128
#include<cstdlib>
#include<cstdio>
int pd(long long m) {
	for(int i=2; i*i<=m; i++)
		if(m%i==0)
			return 0;
	return 1;
}
int main() {
	long long  n,m;
	scanf("%lld%lld",&n,&m);
	if(pd(m)&&n!=1)
		printf("1"),exit(0);
	for(register int i=n; i<=m; i++)
		if(m%i==0)
			printf("%lld",m/i),exit(0);
}

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

namespace ABC148B
{
	class Program
	{
		static void Main(string[] args)
		{
			int a = int.Parse(Console.ReadLine());
			var so = Console.ReadLine().Split(' ');
           
			string b = so[0];
			string c = so[1];
            string ac = b + c;
            int s = 1;
            int i1 = 0;
            char[] aa = b.ToCharArray();
            char[] ab = c.ToCharArray();

            char[] vv = ac.ToCharArray(); 

            vv[0] = aa[0];
            vv[1] = ab[0];
            for (int i = 1; i <= a - 1; i++)
            {
                s++;
                i1++;
                vv[s] = aa[i1];
                s++;
                vv[s] = ab[i1];
            }
            Console.WriteLine(vv);
            Console.ReadKey();
						
		}
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <string.h>
#include <string>

using namespace std;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    for(int i = 0;i < s.length();i++)
    {
        if(int(s[i]) - 65 + n > 25)
        {
            s[i] = s[i] + n - 26;
        }
        else
        {
            s[i] = s[i] + n;
        }
    }
    cout << s;
}

Measured memory_bytes: 256
// ConsoleApplication69.cpp : アプリケーシ
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;

int main()
{

	ll i, j, k, l, m, flag, N, M, K, H, W, X, P,A,B,C;
	cin >> A >> B >> C;
	ll ans;
	if (A + B > C) {
		ans = C + B;
	}
	else if(A+B==C){
		ans = B + C;
	}
	else {
		ans = A + B + 1 + B;
	}
	output(ans);
	
	return 0;
}





Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def solve():
    import sys
    import heapq

    MAX_S = 50*50
    N, M, S = list(map(int, sys.stdin.readline().split()))
    graph = [[] for _ in range(N)]

    for _ in range(M):
        u, v, a, b = list(map(int, sys.stdin.readline().split()))
        u, v = u-1, v-1
        graph[u].append((v, a, b))
        graph[v].append((u, a, b))

    ryogae = []
    for _ in range(N):
        c, d = list(map(int, sys.stdin.readline().split()))
        ryogae.append((c, d))

    # dp[v][s] := 頂点vに所持金sで訪れるときの最小時間
    dp = [[float("inf") for _ in range(MAX_S+1)] for __ in range(N)]

    # ダイクストラ
    s = min(S, MAX_S)
    que = []
    heapq.heappush(que, (0, 0, s))  # (時刻t, 頂点番号v, 所持金s)
    # heapq.heappush(que, (0, s, 0))  # (頂点番号v, 所持金s, 時刻t)

    while len(que) != 0:
        t, v, s = heapq.heappop(que)
        # v, s, t = heapq.heappop(que)

        # if dp[v][s] != t: continue  # なにこれ？

        # 両替する場合
        c, d = ryogae[v]
        ns = min(s+c, MAX_S)
        if dp[v][ns] > t+d:
            dp[v][ns] = t+d
            heapq.heappush(que, (t+d, v, ns))
            # heapq.heappush(que, (v, ns, t+d))

        # 移動する場合(v -> uに移動)
        for u, a, b in graph[v]:
            if s-a < 0: continue
            if dp[u][s-a] > t+b:
                dp[u][s-a] = t+b
                heapq.heappush(que, (t+b, u, s-a))
                # heapq.heappush(que, (u, s-a, t+b))

    for v in range(1, N):
        ans = float("inf")
        for s in range(MAX_S+1):
            ans = min(ans, dp[v][s])
        print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 27944