akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
int main()
{
    int N, Q;
    std::cin >> N >> Q;
    std::vector<int> S(N), T(N), X(N), D(Q);
    for(int i = 0; i < N; i++){std::cin >> S[i]>>T[i]>>X[i], S[i]-=X[i], T[i]-=X[i];}
    for(int i = 0; i < Q; i++){std::cin >> D[i];}
    std::vector<int> V;
    for(int i = 0; i < N; i++){
        for(int d = -1; d<=1; d++){ V.push_back(S[i]+d), V.push_back(T[i]+d); }
    }
    for(int i = 0;i < Q; i++){V.push_back(D[i]);}
    std::sort(V.begin(),V.end());
    V.erase(std::unique(V.begin(),V.end()), V.end());
    const int L = V.size();
    std::map<int,int> zip;
    for(int i = 0; i < L; i++){zip[V[i]]=i;}
    std::vector<std::vector<int>> imos(L+1);
    for(int i = 0; i < N; i++){
        const int s = zip[S[i]], t = zip[T[i]];
        imos[s].push_back(X[i]), imos[t].push_back(-X[i]);
    }
    std::vector<int> stop(L+1, -1);
    std::multiset<int> st;
    for(int i = 0; i <= L; i++){
        for(const int ind: imos[i]){ 
            if(ind > 0) {
                st.insert(ind);
            } else {
                st.erase(-ind);
            }
        }
        stop[i] = st.empty() ? -1 : *st.begin();
    }
    for(int i = 0; i < Q; i++){
        const int p = zip[D[i]];
        std::cout << stop[p] << std::endl;
    }
    return 0;
}


Measured memory_bytes: 135656
import math

a, b, h, m = map(int, input().split())
rad_a = 2 * math.pi / 720 * (60 * h + m)
rad_b = 2 * math.pi / 60 * m

ans = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(rad_a - rad_b))
print("{:.20f}".format(ans))

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


int main(){
  int N;
  cin >> N;
  vector<int> t(N), x(N), y(N);
  for(int i = 0; i < N; i++){
    cin >> t.at(i);
    cin >> x.at(i);
    cin >> y.at(i);
  }
  
  int now_time = 0;
  vector<int> now_pos = {0, 0};
  bool can = true;
  
  for(int i = 0; i < N; i++){
    int distance = abs(x.at(i) - now_pos[0]) + abs(y.at(i) - now_pos[1]);
    int move_time = t.at(i) - now_time;
    if(distance > move_time || (distance - move_time)%2!=0){
      can = false;
      break;
    }
    now_time = t.at(i);
    now_pos  = {x.at(i), y.at(i)};
  }
  
  if(can)	cout << "Yes" << endl;
  else	cout << "No" << endl;

}

Measured memory_bytes: 1408
sa = list(input() + 'A')
sb = list(input() + 'B')
sc = list(input() + 'C')


def f(s):
    c = s.pop(0)
    if c.isupper():
        print(c)
        return
    if c == 'a':
        f(sa)
    elif c == 'b':
        f(sb)
    else:
        f(sc)


f(sa)


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

int main(){
  int N;
  set<string> gacha;
  
  cin >> N;
  for(int i= 1;i<=N;i++){
    string input;
    cin >> input;
    gacha.insert(input);
  }
  cout << gacha.size() << endl;
  
    
  return 0;
}

Measured memory_bytes: 15692
//written by libra9z
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <cmath>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for (int i=0;i<(n);i++)
#define repit(it,a) for (__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define RET(p,x) return p<<x<<endl,0
#define all(a) (a).begin(),(a).end()
#define reunique(v) v.erase(unique(all(v)),v.end())
#define sz(a) (int)a.size()
#define sqr(x) ((x)*(x))
const int inf=1e9;
const ll lnf=1e18;
const int mod=1e9+7;
int h,w;
char s[13][13];
string ss[13];
int a[13];
int b[13];
void dfs1(int x,bool f)
{
	if (x==w)
	{
		puts("YES");
		exit(0);
	}
	else if (b[x]!=-1) dfs1(x+1,f);
	else
	{
		for (int i=x+1;i<w;++i)
		{
			if (b[i]!=-1) continue;
			int j;
			for (j=0;j<h;++j) if (s[j][x]!=s[a[j]][i]) break;
			if (j==h)
			{
				b[x]=i;
				b[i]=x;
				dfs1(x+1,f);
				b[x]=b[i]=-1;
			}
		}
		if (!f)
		{
			int j;
			for (j=0;j<h;++j) if (s[j][x]!=s[a[j]][x]) break;
			if (j==h)
			{
				b[x]=x;
				dfs1(x+1,true);
				b[x]=-1;
			}
		}
	}
}
void dfs2(int x,bool f)
{
	if (x==h) dfs1(0,!(w&1));
	else if (a[x]!=-1) dfs2(x+1,f);
	else
	{
		for (int i=x+1;i<h;++i)
		{
			if (a[i]!=-1) continue;
			if (ss[x]!=ss[i]) continue;
			a[x]=i;
			a[i]=x;
			dfs2(x+1,f);
			a[x]=a[i]=-1;
		}
		if (!f)
		{
			a[x]=x;
			dfs2(x+1,true);
			a[x]=-1;
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie();cout.tie();
	cout<<setprecision(15);
	cin>>h>>w;
	for (int i=0;i<h;++i) cin>>s[i],ss[i]=s[i],sort(ss[i].begin(),ss[i].end());
	for (int i=0;i<800000000;++i);
	for (int i=0;i<h;++i) a[i]=-1;
	for (int i=0;i<w;++i) b[i]=-1;
	dfs2(0,!(h&1));
	cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
template<typename T>void max_self(T &a,T b){a=max(a,b);}
template<typename T>void min_self(T &a,T b){a=min(a,b);}
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=3e5+10,oo=0x3f3f3f3f,MOD=998244353;
const long double PI = acos(-1),eps=1.0e-14;

void solve(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l[mxN]={};
    loop(n,i,0){
        l[i+1]=(l[i]+(s[i]=='E'));
    }
    int res=1e9;
    loop(n+1,i,0){
        int x1=(i-l[i]),x2=(l[n]-l[i]);
        min_self(res,x1+x2);
    }
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 4852
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int n = str.length();
        char c[] = str.toCharArray();
        for (int i = 0; i < n / 2; i++) {
            if (c[i] != c[n-1-i]) {
                System.out.println("No");
                return;
            }
        }
        for (int i = 1 - 1; i < (n - 1) / 2; i++) {
            if (c[i] != c[(n-1)/2 - 1 - i]) {
                System.out.println("No");
                return;
            }
        }
        int j = n - 1;
        for (int i = (n + 3) / 2 - 1; i < n; i++) {
            if (c[i] != c[j--]) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    int d[5];
    REP(i,5){
	cin >> d[i];
    }
    int ans = 10000000;
    REP(i,2)REP(j,3){
	ans = min(ans, d[3+i]+d[j]-50);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>
 
// #include <unordered_set>
// #include <unordered_map>
 
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
 
#define pb push_back
#define mp make_pair
 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
 
typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;
 
const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
 
using namespace std;
 
#define N 1000000
int arr[N];
int a[N];
 
signed main(int argc, char const *argv[])
{
    int x,y,z;
    cin>>x>>y>>z;

    REP(i,1000007){

        int tmp=i*(y+z)+z;
        if(tmp==x){
            // cout<<"match"<<endl;
            cout<<i<<endl;
            break;
        }else if(tmp>x){
            cout<<i-1<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N,M;
  cin>>N>>M;
  vector<vector<int>> g(N);
  rep(i,M){
    int a,b;
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> dist(N,MOD),ans(N,-1);
  queue<int> Q;
  Q.push(0);
  dist[0]=0;
  while(!Q.empty()){
    int now=Q.front();
    Q.pop();

    for(auto nex:g[now]){
      if(dist[nex]==MOD){
        dist[nex]=dist[now]+1;
        Q.push(nex);
        ans[nex]=now;
      }
    }
  }

  cout<<"Yes"<<"\n";
  for(int i=1;i<N;i++) cout<<ans[i]+1<<"\n";

  return 0;
}


Measured memory_bytes: 10636
#include <bits/stdc++.h>
    
using namespace std;
    
#define endl "\n";
typedef long long ll;
typedef unsigned long long ull;   
const int N = 2*1e5+10;

ll x;
ll n,k;
int arr[N];
string s,t;

int main()
{
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    cin>>n;
    if(n%2||n<10)
        cout<<0;
    else
    {
        ll ans = 0;
        for(ll i=10;i<=n;i*=5)
            ans+=n/i;
        cout<<ans;
    }
    
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
int main()
{ 
    cool;
    ll int n,m;
    cin>>n>>m;
    ll int a[n+1],b[n+1]={0};
    for(ll int i=1;i<=n;i++)
    cin>>a[i];
    while(m--){
    	ll int x,y;
    	cin>>x>>y;
    	if(a[x]==a[y])
    	{
    		b[x]=-1;
    		b[y]=-1;
		}
    	else if(a[x]>a[y]){
    		b[y]=-1;
		}
		else if(a[x]<a[y]){
			b[x]=-1;
		}
	}
	ll int cnt=0;
	for(ll int i=1;i<=n;i++){
		if(b[i]==0){
			cnt++;
		}
	}
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 5092
#include<bits/stdc++.h>
#define max 1000000000
using namespace std;
typedef long long ll;
int n,m,x;
int arr[20];
int mtr[20][20];
int sum[20];
int dp(int pos,int store[])
{
	int flag=0;
	for(int i=0; i<m; i++)
	{
		if(store[i]<x){
			flag=1;
			break;
		}
	}
	if(flag==1 && pos==n)
	 return max;
	if(flag==0)
	 return 0;
	int price2=dp(pos+1,store);
	for(int i=0; i<m; i++)
	{
		store[i]+=mtr[pos][i];
	}
	int price1=arr[pos]+dp(pos+1,store);
	for(int i=0; i<m; i++)
	 store[i]-=mtr[pos][i];
	return min(price1,price2);
	
}
int main()
{
	int require[20];
	memset(require,0,sizeof(require));
/*	for(int i=0; i<20; i++)
	 cout<<require[i]<<" ";*/
	cin>>n>>m>>x;
	memset(sum,0,sizeof(sum));
	for(int i=0; i<n; i++)
	{
		cin>>arr[i];
		for(int j=0; j<m; j++){
		 cin>>mtr[i][j];
		 sum[j]=sum[j]+mtr[i][j];
	    }
	}
	int flag=0;
	for(int i=0; i<m; i++)
	{
		if(sum[i]<x){
			flag=1;
			break;
		}
	}
	if(flag==1)
	 cout<<"-1";
	else
	{
		int ans=dp(0,require);
		cout<<ans;
	}
return 0;	
}

Measured memory_bytes: 3628
n=int(input())
a=list(map(int,input().split()))

l=[0]*(10**6+1)
ans=0
#print(l)
for i in a:
    if l[i]==0:
        for j in range(i,10**6+1,i):
            l[j] += 1
    else:
        l[i] += 1
#print(l)
for i in a:
    if l[i]==1:
        ans+=1

print(ans)

Measured memory_bytes: 32196
import math

# 入力を取得
A, B, H, M = map(int, input().split())

min = 60 * H + M

# 時針の角度を求める。
deg_H = (H + M / 60) / 12 * 360

# 分針の角度を求める。
if M != 0:
    deg_M = M / 60 * 360
else:
    deg_M = 360

# 針の角度の差を求める。
t = abs(deg_H - deg_M)

# 余弦定理の公式に当てはめる。
ans = math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(t)))
print(ans)

Measured memory_bytes: 9492
N = int(input())
A = list(map(int,input().split()))
color = [0] * 9
flag = False
for i in range(len(A)):
	flag = False
	for j in range(8):
		if 400 * j <= A[i] and A[i] <= 400 * (j + 1) - 1:
			color[j] = 1
			flag = True
	if flag == False:
		color[-1] += 1
print(max(sum(color[:-1]),1),sum(color))

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

int main()
{
    INT n,m,ans;
    while(scanf("%lld %lld",&n,&m)==2)
    {
        ans = (n*(n-1))/2 + (m*(m-1))/2;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {

    static List<String> z;

    public static void permutation(String q, String ans) {
        if (q.length() <= 1) {
            z.add(ans + q);
        } else {
            for (int i = 0; i < q.length(); i++) {
                permutation(q.substring(0, i) + q.substring(i + 1), ans + q.charAt(i));
            }
        }
    }

    public static void main(String[] args) {
        z = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] Xz = new int[N];
        int[] Yz = new int[N];

        for (int i = 0; i < N; i++){
            Xz[i] = sc.nextInt();
            Yz[i] = sc.nextInt();
        }

        StringBuilder sb = new StringBuilder();

        for (int n = 0; n < N; n++) {
            sb.append(Integer.toString(n));
        }

        permutation(sb.toString(), "");

        int cnt = 0; double sum = 0; double diff = 0;
        String text = "";
        for (int i = 0; i < z.size(); i++) {
//            System.out.println(z.get(i));
            text = z.get(i).toString();
            cnt++;
            diff = 0;
            double left = 0; double right = 0;
            for (int j = 1; j < N; j++){
//                System.out.println("aaaa");
//                System.out.println(text.charAt(j - 1));
//                System.out.println(text.charAt(j));
//                System.out.println(Xz[text.charAt(j - 1) - 48]);
//                System.out.println(Xz[text.charAt(j) - 48]);
//                System.out.println(Yz[text.charAt(j - 1) - 48]);
//                System.out.println(Yz[text.charAt(j) - 48]);
//                System.out.println((Xz[text.charAt(j - 1) - 48]));// - Xz[text.charAt(j)]));
                left = Math.pow((Xz[text.charAt(j - 1) - 48] - Xz[text.charAt(j) - 48]), 2);
//                System.out.println(left);
                right = Math.pow((Yz[text.charAt(j - 1) - 48] - Yz[text.charAt(j) - 48]), 2);
//                System.out.println(right);
                diff += Math.sqrt(Math.pow((Xz[text.charAt(j - 1) - 48] - Xz[text.charAt(j) - 48]), 2) + Math.pow((Yz[text.charAt(j - 1) - 48] - Yz[text.charAt(j) - 48]), 2));
            }
//            double mean = (double) diff / (N-1);
            double mean = diff;
//            System.out.println("mean: "+mean);
//            sum += diff / (N-1);
            sum += mean;
//            System.out.println("sumaa: "+sum);
        }

//        System.out.println("sum: "+sum);
//        System.out.println("cnt: "+cnt);
        System.out.println((double) (sum / cnt));




    }
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int i = 0;
    int mi = 0;
    for (char c : s) {
        if (c == ')') {
            i--;
            cmin(mi, i);
        } else {
            i++;
        }
    }

    string t = "";
    for (int k = mi; k < 0; k++) {
        t += '(';
    }
    t += s;

    int j = 0;
    for (char c : t) {
        if (c == ')') {
            j--;
        } else {
            j++;
        }
    }

    for (int i = 0; i < j; i++) {
        t += ')';
    }
    cout << t << endl;

}

Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand rng
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define M_PI 3.14159265358979323846
typedef long long ll;



int main() {
	//fios;
	ll n;
	cin >> n;
	vector<ll> a(n);
	ll xr = 0;
	for(auto& x: a) cin >> x, xr ^= x;

	for(int i = 0; i < n; i++) {
		cout << (xr ^ a[i]) << endl;
	}

}

Measured memory_bytes: 4804
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
#define ln endl
const int N=1e5+5;
map<string,int> mp;
int n;
ll ans,cnt;
int main() {
	n=_;
	for( int i=1;i<=n;i++ ) {
		char s[10];
		scanf("%s",s); int len=strlen(s);
 		sort(s,s+len);
 		ans+=mp[s];
 		mp[s]++;
	}
	cout<<ans<<ln;
}

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

int main(void){
    int x;
    cin >> x;
    int l = 0, r = 0;
    while(l <= x){
        if (l <= x && x <= r) {
            cout << 1 << endl;
            return 0;
        }
        l += 100;
        r += 105;
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
import scala.math.pow

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var s = sc.next()
  var t = sc.next()
  var ans = 0
  for(i <- 0 until s.length){
    if (s(i)!= t(i)){
      ans += 1
    }
  }
  println(ans)
}


Measured memory_bytes: 58356
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mp(x,y) make_pair(x,y)
const int nax=2e5+5;
const int mod=998244353;
ll fact[nax];
ll inv[nax];
ll fun(ll a, ll b){
    if(b==0) return 1;
    ll g=fun(a,b/2);
    g*=g; g%=mod;
    if(b&1) g*=a;
    return g%mod;
}
ll ncr(ll n, ll r){
    return (fact[n] * ((  (inv[r]*inv[n-r])%mod  )%mod) )%mod;
}
void solve(){
    fact[0]=1;
    inv[0]=1;
    for(int i=1;i<nax;i++){
        fact[i]=(fact[i-1]*i)%mod;
        inv[i]=(inv[i-1]*fun(i,mod-2))%mod;
    }
    ll n,m,k;
    cin>>n>>m>>k;  
    ll ans=0;
    for(int i=0;i<=k;i++){
        ll r=m;
        r=(r*fun(m-1,n-i-1))%mod;
        r*=ncr(n-1,i);
        r%=mod;
        ans=(ans+r)%mod;
    }
    cout<<ans<<'\n';
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int tc;
    tc=1;
    while(tc--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 6768
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered1 tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define inf mod1
#define all(x) x.begin(),x.end()
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
int main(){
	fast;
	ll h = 1;
	//cin >> h;
    while(h--){
 	ll h, n;
 	cin >> h >> n;
 	ll a[n];
 	for(int i = 0; i < n ;i++){
 		cin >> a[i];
 		h -= a[i];
 	}    
 	if(h <= 0){
 		cout << "Yes" << endl;
 	}
 	else{
 		cout << "No" << endl;
 	}
}
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    string s;
    cin >> s;
    if (s.at(0) == s.at(1) && s.at(1) == s.at(2)) {
        cout << "No" << endl;
    }
    else cout << "Yes" << endl;
}


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

int main(int argc, char *argv[])
{
    string taro, hanako;
    int count, taro_point = 0, hanako_point = 0;
    cin >> count;
    while (count--)
    {
        cin >> taro >> hanako;
        if (taro > hanako)
            taro_point += 3;
        else if (taro < hanako)
            hanako_point += 3;
        else if (taro == hanako)
        {
            taro_point++;
            hanako_point++;
        }
    }
    cout << taro_point << " " << hanako_point << endl;

    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#include <assert.h>

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

using namespace std;

map<int, vector<int>> graph;

void wfs(int a, int s, vector<int> &cost, vector<int> &color) {
    queue<pair<int, int>> que;
    que.push({ s, 0 });
    color[s] = a;
    cost[s] = 0;

    while (!que.empty()) {
        pair<int, int> n = que.front(); que.pop();
        FOE(x, graph[n.first]) {
            if (cost[x] > n.second + 1) {
                cost[x] = n.second + 1;
                color[x] = a;
                que.push({ x, n.second + 1 });
            }
        }
    }

}

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, a, b;
    cin >> N;
    FOR(_, 0, N - 1) {
        cin >> a >> b;
        a--; b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    vector<int> cost(N, INT_MAX / 2);
    vector<int> color(N, 0);
    wfs(1, 0, cost, color);
    wfs(-1, N - 1, cost, color);

    cout << (SUM(color) > 0 ? "Fennec" : "Snuke") << endl;

    return 0;
}


Measured memory_bytes: 12032
import itertools as itl
n, m=map(int, input().split())
#ここでリストを作成する
hen=[]
check=0

for _ in range(m):
  hen.append(list(map(int, input().split())))
#print(hen)
l=list(range(2, n+1))
for v in itl.permutations(l):
  #print(v)
  for i in range(n-2):
    if not(sorted(v[i:i+2]) in hen) or not(list([1, v[0]]) in hen):
      break
  else:
    if n==2:
      check+=1
    elif i==n-3:
      check+=1
    continue
print(check)
  
  
      
    

Measured memory_bytes: 3064
read M D
for m in $(seq 4 $M)
do
  for d10 in $(seq 2 $((D/10)))
  do
    t_d=$((D-d10*10))
    (( t_d < 10 )) || t_d=9
    for d1 in $(seq 2 $((t_d)))
    do
      [[ m -eq d10*d1 ]] && ((c++))
    done
  done
done
echo $((c))

Measured memory_bytes: 1576
N, K = map(int, input().split())
v = list(map(int, input().split()))
ans = 0

for i in range(min(K + 1, N + 1)):
    for j in range(min(K + 1 - i, N + 1 - i)):
        d = K - i -j
        nowlst = v[:i] + v[N - j:]
        nowlst.sort(reverse=True)
        for k in range(d):
            if nowlst != [] and nowlst[-1] < 0:
                nowlst.pop()
            else:
                break
        ans = max(ans, sum(nowlst))

print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
#include<string.h>
#define LEN 100005


/*プロセスを表す構造体*/
typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head +1) % LEN;
    return x;
}

int min(int a, int b){ return a < b ? a : b;} /* 最小値を返す */

int main(){
    int elaps = 0, c;
    int i, q;
    P u;

    scanf("%d %d", &n, &q);

    /*全てのプロセスをキューに順番に追加する。*/
    for ( i = 1; i <= n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    /*Qのインデックスであるhead.tailを初期化*/
    head = 1; tail =n+1;

    /*しみゅれーション*/
    while ( head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if (u.t > 0)enqueue(u);
        else{
            printf("%s %d\n",u.name, elaps);
        }
    }
    return 0;
    
}


Measured memory_bytes: 12720
#coding: utf-8
s = str(input())
child = [0] * len(s)
# for j in range(len(s)):
# 	child[j] = 1
r = 0
l = 0
# lIdx = 0
rIdx = 0

for i in range(len(s)):
	# print(str(r)+","+str(l))
	if s[i] == 'R':
		# print(i)
		r = r+1
		if s[i+1] == 'L':
			rIdx = i
	elif s[i] == 'L':
		l = l+1
		if i == len(s)-1 or s[i+1] == 'R':
			#1セットが終了する
			# print('r='+str(r)+" l="+str(l))
			if ((r+l)%2) == 0:
				child[rIdx] = (r+l)//2
				child[rIdx+1] = (r+l)//2
			else:
				if r%2==0:
					child[rIdx+1] = (r+l)//2 + 1
					child[rIdx] = (r+l)//2
				else:
					child[rIdx+1] = (r+l)//2
					child[rIdx] = (r+l)//2 + 1
			r = 0
			l = 0
			# lIdx = i-1
# child[rIdx-1] = l

#roop終わらない解法
# for j in range(10 ** 100):
# 	after = [0] * len(s)
# 	for i in range(len(s)):
# 		# print(i)
# 		if child[i] != 0:
# 			if s[i] == 'R':
# 				after[i+1] = after[i+1] + child[i]
# 				# child[i] = 0
# 			elif s[i] == 'L':
# 				after[i-1] = after[i-1] + child[i]
# 				# child[i] = 0
# 	child = after

print(" ".join(map(str,child)))


Measured memory_bytes: 10484
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int cnt=0;
  int g[101];
  int gn[101];  
  int x=1;
  gn[0]=x;
  int l=1;
  while(1){
    x*=2;
    if(n<x)break;
    gn[l]=x;
    l++;
  }
  int m=l;
  for(int i=m-1,j=0;i>=0;i--,j++){
    g[j]=gn[i];
  }
  for(int i=0;i<m;i++){
    //insert
    for(int j=g[i];j<n;j++){
      int v=a[j];
      int k=j-g[i];
      while(k>=0&&a[k]>v){
	a[k+g[i]]=a[k];
	k-=g[i];
	cnt++;
      }
      a[k+g[i]]=v;
    }
  }
  cout << m << endl;
  for(int i=0;i<m;i++){
    cout << g[i];
    if(i+1!=m)cout << " ";
  }
  cout << endl;
  cout << cnt<<endl;
  for(int i=0;i<n;i++){
    cout << a[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 6728
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int d,i,j,cnt=0,cnt1=0;
    cin >> d;
    cin >> s;
    string p="ABC";
    int d1=3;
    for(i=0;i<=d-d1;i++){
            cnt=1;
            for(j=0;j<d1;j++){
        if(p[j]!=s[i+j]){
                cnt=0;
        break;
        }
            }

        if(cnt==1)
            cnt1++;
            }


        cout << cnt1 << endl;
    return 0;


}


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

int main()
{
	ios::sync_with_stdio(false);
	int n,maxv,maxn,x;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(i>1&&abs(x)>abs(maxv)) maxv=x,maxn=i;
		else if(i==1) maxv=x,maxn=i;
	}
	cout<<2*n-1<<'\n';
	for(int i=1;i<=n;i++)
		if(i!=maxn) cout<<maxn<<' '<<i<<'\n';
	cout<<maxn<<' '<<maxn<<'\n';
	if(maxv>0) for(int i=1;i<n;i++) cout<<i<<' '<<i+1<<'\n';
	else for(int i=n;i>1;i--) cout<<i<<' '<<i-1<<'\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll P, ll Q, ll R) {
  cout << P + Q + R - max({P,Q,R}) << endl;
}

int main() {
  ll P;
  cin >> P;
  ll Q;
  cin >> Q;
  ll R;
  cin >> R;
  solve(P, Q, R);
  return 0;
}


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

int main(){
  	int a=0;
 	string s;
  	cin>>s;
  		if(s[0]=='1'){
      		a=a+1;
    		}
  		if(s[1]=='1'){
      		a=a+1;
    		}
  		if(s[2]=='1'){
      		a=a+1;
    		}
  	cout<<a<<endl;
  	return 0;
	}


Measured memory_bytes: 256
N = int(input())
H = [int(x) for x in input().split()]

dp = [0] * N
dp[1] = abs(H[1]-H[0])
for i in range(2,N):
    dp[i] = min(dp[i-k] + abs(H[i]-H[i-k]) for k in [1,2])

answer = dp[-1]
print(answer)


Measured memory_bytes: 13780
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N, M;
    cin>>N>>M;
    vector<string> S(N);
    REP(i, 0, N) cin >> S[i];

    mf_graph<int> g(N * M + 2);
    int s = N * M, t = N * M + 1;

    REP(i, 0, N){
        REP(j, 0, M){
            if(S[i][j] == '#') continue;
            int v = i * M + j;
            if((i + j) % 2 == 0){
                g.add_edge(s, v, 1);
            }else{
                g.add_edge(v, t, 1);
            }
        }
    }

    REP(i, 0, N){
        REP(j, 0, M){
            if((i+j) % 2 || S[i][j] == '#') continue;
            int v0 = i * M + j;
            if(i && S[i-1][j] == '.'){
                int v1 = (i - 1) * M + j;
                g.add_edge(v0, v1, 1);
            }
            if(j && S[i][j-1] == '.'){
                int v1 = i * M + j - 1;
                g.add_edge(v0, v1, 1);
            }
            if(i + 1 < N && S[i + 1][j] == '.'){
                int v1 = (i + 1) * M + j;
                g.add_edge(v0, v1, 1);
            }
            if(j + 1 < M && S[i][j + 1] == '.'){
                int v1 = i * M + j + 1;
                g.add_edge(v0, v1, 1);
            }
        }
    }
    cout << g.flow(s, t) << endl;

    auto edges = g.edges();
    for(auto e: edges){
        if(e.from == s || e.to == t || e.flow == 0) continue;
        int i0 = e.from / M, j0 = e.from % M;
        int i1 = e.to / M, j1 = e.to % M;

        if(i0 == i1 + 1){
            S[i1][j1] = 'v';
            S[i0][j0] = '^';
        }else if(j0 == j1 + 1){
            S[i1][j1] = '>'; S[i0][j0] = '<';
        }else if(i0 == i1 - 1){
            S[i0][j0] = 'v';
            S[i1][j1] = '^';            
        }else{
            S[i0][j0] = '>'; S[i1][j1] = '<';
        }
    }
    REP(i, 0, N){
        cout << S[i] << endl;
    }
}

Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return 0;
}


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

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static List<string> cons = new List<string>();
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] str = Console.ReadLine().Split(' ');
            Int64[] mon = new Int64[n + 1];
            for (int i = 0; i < n + 1; i++)
            {
                mon[i] = int.Parse(str[i]);
            }

            string[] str2 = Console.ReadLine().Split(' ');
            Int64[] bra = new Int64[n];

            for (int i = 0; i < n; i++)
            {
                bra[i] = int.Parse(str2[i]);
            }

            Int64 res = recursive(mon, bra, n);
            Console.WriteLine(res);
        }


        private static Int64 recursive(Int64[] mon, Int64[] bra, int n)
        {
            if (n == 0) return 0;
            if (mon[n] >= bra[n - 1])
            {
                return bra[n - 1] + recursive(mon, bra, n - 1);
            }
            else
            {
                Int64 hit = mon[n];
                bra[n - 1] -= hit;
                if (bra[n - 1] <= mon[n - 1])
                {
                    hit += bra[n - 1];
                    mon[n - 1] -= bra[n - 1];
                }
                else
                {
                    hit += mon[n - 1];
                    mon[n - 1] = 0;
                }

                return hit + recursive(mon, bra, n - 1);
            }
        }
    }
}


Measured memory_bytes: 40656
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b != c){
        cout << "Yes" << endl;
    }else if(a == c && c != b){
        cout << "Yes" << endl;
    }else if(b == c && a != b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
use std::io::{BufRead, BufReader};
use std::collections::HashMap;

fn main(){
    let lines = read::<String>();
    let nm:Vec<i32> = lines[0].split(' ').map(|i| i.parse().unwrap()).collect();
    let n = nm[0];
    let m = nm[1];

    let mut hash: HashMap<i32,i32> = HashMap::new();
    let mut can_solve = true;

    lines
        .into_iter()
        .skip(1)
        .map(|l| {
            let sc: Vec<i32> = l.split(' ').map(|i| i.parse().unwrap()).collect();
            let s: i32 = sc[0];
            let c: i32 = sc[1];
            let x = hash.entry(s).or_insert(c);
            if *x != c {
                can_solve = false;
            } else if  n != 1 && s == 1 && *x == 0 {
                can_solve = false;
            };
        }).count();

    let mut ans: i32 = 0;
    if !can_solve {
        ans = -1;
    } else {
        let mut base: i32 = {
            if n == 1 && m == 0 {
                0
            } else {
                1
            }
        };

        for i in 1..n+1 {
            let k: u32 = (n - i) as u32;
            ans +=  *hash.entry(i).or_insert(base) * 10i32.pow(k);
            base = 0;
        }
    }

    println!("{}", ans);
}

fn read<T>() -> Vec<T>
where
  T: std::str::FromStr,
  T::Err: std::fmt::Debug,
{
    let lines: Vec<T> =
        BufReader::new(std::io::stdin())
        .lines()
        .map(|l| l.unwrap().parse::<T>().unwrap())
        .collect();
    lines
}



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

typedef long long LL;

int lstl, lstL, l, L, n;
std::priority_queue<LL> left;
std::priority_queue<LL, std::vector<LL>, std::greater<LL>> right;
LL tagL, tagR, ans;

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> lstl >> lstL, lstL -= lstl;
	left.emplace(lstl), right.emplace(lstl);
	for (int i = 1; i < n; ++i) {
		std::cin >> l >> L, L -= l;
		tagL -= L, tagR += lstL;
		int ltop = left.top() + tagL, rtop = right.top() + tagR;
		if (l > ltop) {
			right.emplace(l - tagR), right.emplace(l - tagR);
			int rtop = right.top() + tagR; right.pop();
			ans += l - rtop, left.emplace(rtop - tagL);
		} else {
			left.emplace(l - tagL), left.emplace(l - tagL);
			int ltop = left.top() + tagL; left.pop(); 
			ans += ltop - l, right.emplace(ltop - tagR);
		}
		lstl = l, lstL = L;
	}
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 2036
using System;

namespace AtCoderWorkspace
{
    public class Program
    {
        private static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');

            int a, b = 0;
            int.TryParse(inputs[0],out a);
            int.TryParse(inputs[1],out b);

            var sum = a + b;
            var multi = a * b;
            var diff = a - b;

            var max = sum;
            if (max < multi)
            {
                max = multi;
            }

            if (max < diff)
            {
                max = diff;
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<math.h>
 
int main(){
    int step, angle;
    double x = 0, y = 0, angle_all = 0;

    while(1){
        scanf("%d, %d", &step, &angle);

        if(step == 0 && angle == 0)break;

        x += -step * sin(angle_all * M_PI / 180);
        y += step * cos(angle_all * M_PI / 180);

        angle_all -= angle;

        }

    printf("%d\n", (int)x);
    printf("%d\n", (int)y);
    return 0;
}

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

int main() {

    int X, Y;
    cin >> X >> Y;

    bool exist = false;
    for (int x = 0; x <= 100; x++) {
        int y = X - x;

        if (x >= 0 && y >= 0 && 2*x + 4*y == Y) {
            exist = true;
            break;
        }
    }
    cout << ((exist)? "Yes": "No") << endl;

    return 0;
}

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

using namespace std;

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

void rwf() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

const int N = 105, mxW = 1e5 + 5;
int n, W, w[N], v[N];

int dp[N][mxW];

int solve(int wr, int m) {
	if (m == 0 || wr == 0)
		return 0;

	if (dp[m][wr] != -1)
		return dp[m][wr];

	if (wr - w[m] < 0)
		return dp[m][wr] = solve(wr, m - 1);

	return dp[m][wr] = max(solve(wr, m - 1), v[m] + solve(wr - w[m], m - 1));
}

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

	//rwf();

	cin >> n >> W;

	memset(&dp, -1, sizeof(dp));

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

	int ans = solve(W, n);

	cout << ans;

	return 0;
}

Measured memory_bytes: 82304
import java.util.*;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<Integer,Integer> s = new HashMap<>();
        for (int i = 0; i < N; i++) {
            int n=sc.nextInt();

            if(!s.containsKey(n)){
                s.put(n,1);
            }else{
                s.put(n,s.get(n)+1);
            }
        }


        if(s.size() > 3){
            System.out.println("No");
            return;
        }

        Set<Integer> ks = s.keySet();
        Object[] arr = ks.toArray();
        if(s.size()==1){
            int v = (Integer)arr[0];
            if( (v ^ v) != v){
                System.out.println("No");
                return;
            }
        }else if(s.size()==2){
            if(N%3 != 0 ){
                System.out.println("No");
                return;
            }

            int v1 = (Integer)arr[0];
            int v2 = (Integer)arr[1];
            int n1 = s.get(v1);
            int n2 = s.get(v2);
            if(n1!=n2*2 && n1*2!=n2){
                System.out.println("No");
                return;
            }
            if(n1==n2*2 && (v1 ^ v1) != v2){
                System.out.println("No");
                return;
            }
            if(n1*2==n2 && (v2 ^ v2) != v1){
                System.out.println("No");
                return;
            }


        }else{//3

            if(N%3 != 0 ){
                System.out.println("No");
                return;
            }

            int v1 = (Integer)arr[0];
            int v2 = (Integer)arr[1];
            int v3 = (Integer)arr[2];
            if( (v1 ^ v2) != v3){
                System.out.println("No");
                return;
            }
            int n1 = s.get(v1);
            int n2 = s.get(v2);
            int n3 = s.get(v3);
            if(n1 != n2 || n2 != n3 || n1 != n3 ){
                System.out.println("No");
                return;
            }
        }




        System.out.println("Yes");

    }
}


Measured memory_bytes: 61936
//2018.09.21 2.5min

#include <iostream>
using namespace std;

int main() {

    string s,t;
    cin >> s >> t;


    int len = s.size();
    string ans = "No";
    string test = t;

    for(int i=0;i<len;i++){
        if(s==test){ans="Yes"; break;}
        test = test[len-1] + test.substr(0,len-1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int N,i;
    double A[1000],sum=0.0;
	scanf("%d\n", &N);
	for (i = 0; i < N; i++) {
		scanf("%lf", &A[i]);
		sum += 1.0/A[i];
	}
	printf("%f", 1.0 / sum);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
const ll mod=1e9+7;
 
ll modpow(ll a,ll b){
  ll ans=1%mod;
  while(b){	
    if(b&1) ans=(ans*a)%mod;
    a=(a*a)%mod;
    b=b>>1; 
  }
  return ans;
  }
 
int main(){
  ll N;cin>>N;
  ll ans = modpow(10, N) - 2 * modpow(9, N) + modpow(8, N);
  ans %= mod;
  ans = (ans + mod) % mod;
  cout << ans << endl;
}

Measured memory_bytes: 3492
# include <iostream>
# include <cmath>
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <vector>
# define pb push_back
using namespace std;
typedef long long LL;
int main()
{
    int n, a, b;
    scanf("%d%d%d",&n,&a,&b);
    printf("%d\n",min(n*a, b));
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var S = cin.ReadLine();
            var set = new HashSet<char>(S.ToArray());
            if (set.Count == 26) WriteLine("None");
            else
            {
                for (var i = 0; i < 26; ++i)
                {
                    if (!set.Contains((char)('a' + i)))
                    {
                        WriteLine((char)('a' + i));
                        break;
                    }
                }
            }
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}


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

int a, b, k, c = 0;
int main() {
  cin >> a >> b >> k;
  for (int i = 100; i > 0; i--) {
    if (a % i == 0 && b % i == 0) {
      c++;
    }
    if (c == k) {
      cout << i << '\n';
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256