akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cctype>
#include<vector>
#include<queue>
#include<algorithm>
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
typedef long long ll;
const int maxn=250;
const int inf=1e9;
const int maxm=20050;
struct edge{
    int to,cap,rev;
};
struct Dinic {
    int n,m;
    edge w[maxm];
    int fr[maxm];
    int num[maxn],cur[maxn],first[maxn];
    edge e[maxm];
    void init(int n){
        this->n=n;
        m=0;
    }
    void AddEdge(int from,int to,int cap){
        w[++m]=(edge){to,cap};
        num[from]++,fr[m]=from;
        w[++m]=(edge){from,cap};
        num[to]++,fr[m]=to;
    }
    void prepare(){
        first[1]=1;
        for(int i=2;i<=n;i++)
            first[i]=first[i-1]+num[i-1];
        for(int i=1;i<n;i++)
            num[i]=first[i+1]-1;
        num[n]=m;
        for(int i=1;i<=m;i++){
            e[first[fr[i]]+(cur[fr[i]]++)]=w[i];

            if (!(i%2)){
                e[first[fr[i]]+cur[fr[i]]-1].rev=first[w[i].to]+cur[w[i].to]-1;
                e[first[w[i].to]+cur[w[i].to]-1].rev=first[fr[i]]+cur[fr[i]]-1;
            }
        }
    }
    int q[maxn];
    int dist[maxn];
    int t;
    bool bfs(int s){
        int l=1,r=1;
        q[1]=s;
        memset(dist,-1,(n+1)*4);
        dist[s]=0;
        while(l<=r){
            int u=q[l++];
            for(int i=first[u];i<=num[u];i++){
                int v=e[i].to;
                if ((dist[v]!=-1) || (!e[i].cap))
                    continue;
                dist[v]=dist[u]+1;
                if (v==t)
                    return true;
                q[++r]=v;
            }
        }
        return dist[t]!=-1;
    }
    int dfs(int u,int flow){
        if (u==t)
            return flow;
        for(int& i=cur[u];i<=num[u];i++){
            int v=e[i].to;
            if (!e[i].cap || dist[v]!=dist[u]+1)
                continue;
            int t=dfs(v,min(flow,e[i].cap));
            if (t){
                e[i].cap-=t;
                e[e[i].rev].cap+=t;
                return t;
            }
        }
        return 0;
    }
    int solve(int s,int t){
        int ans=0;
        this->t=t;
        while(bfs(s)){
            int flow;
            for(int i=1;i<=n;i++)
                cur[i]=first[i];
            while(flow=dfs(s,inf))
                ans+=flow;
        }
        return ans;
    }
}sol;
int n,m;
char M[maxn][maxn];
int main() {
	scanf("%d%d",&n,&m);
	rep(i,1,n) scanf("%s",M[i]+1);
	sol.init(n+m+2);
	rep(i,1,n) rep(j,1,m) {
		if(M[i][j]=='o') sol.AddEdge(i,j+n,1);
		else if(M[i][j]=='S'||M[i][j]=='T') sol.AddEdge(i,j+n,inf);
	}
	int sx,sy,tx,ty;
	rep(i,1,n) rep(j,1,m) {
		if(M[i][j]=='S') sx=i,sy=j;
		if(M[i][j]=='T') tx=i,ty=j;
	}
	int S=n+m+1,T=n+m+2;
	sol.AddEdge(S,sx,inf);sol.AddEdge(S,sy+n,inf);
	sol.AddEdge(tx,T,inf);sol.AddEdge(ty+n,T,inf);
	sol.prepare();
	int ans=sol.solve(S,T);
	printf("%d\n",ans>=inf?-1:ans);
	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll n,m;
ll a[200010];
ll b[200010];
int main(){
	scanf("%lld%lld",&n,&m);
	rep(i,0,m){
		ll p,q;
		scanf("%lld%lld",&p,&q);
		if(p==1)a[q]=1;
		if(q==n)b[p]=1;
	}
	rep(i,2,n)if(a[i]&&b[i]){
		puts("POSSIBLE");
		return 0;
	}
	puts("IMPOSSIBLE");
}

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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loop1(i,a,b) for(int i=a;i<=b;i++)
#define rloop(i,a,b) for(int i=a;i>b;i--)
#define rloop1(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])
#define modInv(a) binExp(a,mod-2)
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)

bool isPrime(int num){
    bool flag=true;
    for(int i = 2; i <=sqrt(num); i++) {
       if(num % i == 0) {
          flag = false;
          break;
       }
    }
    return flag;
}
int dp[100005];
signed main()
{
   int n,k;
   cin>>n>>k;
   int arr[n+1];
   loop1(i,1,n)cin>>arr[i];
   dp[2]=abs(arr[2]-arr[1]);
   loop1(i,3,n){
       int minn=10000000000007;
       loop1(j,1,min(i-1,k)){
         minn=min(dp[i-j]+abs(arr[i]-arr[i-j]),minn);
       }
       dp[i]=minn;

   }
   cout<<dp[n];
}


Measured memory_bytes: 5168
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int sita,m,h;
	scanf("%d",&sita);
	h=sita/30;
	sita=sita%30;
	m=sita*2;
	printf("%d %d\n",h,m);
	return 0;
}


Measured memory_bytes: 2752
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<string>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<chrono>
//#include<time.h>
//#include<windows.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
struct edge {int /*from,*/to,cost;};

main(){
    int n,m;
    string s;
    cin >> n;

    printf("%d\n",n/3);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>array;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        array.push_back(tmp);
    }
    int max=array[0];
    int ans=1;
    for(int i=1;i<array.size();i++){
        if(array[i]<max){
            ans++;
            max=array[i];
        }else{
            continue;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include <iostream> 
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <set>
#include <algorithm>
using namespace std;
#define ll long long int

bool isPalindrome(int num) {
  string s = to_string(num);
  bool diffrent_exist = true;
  for ( int i = 0; i < s.size(); i++ ) {
    if( i == (s.size()/2 ) ) continue;
    if(s[i] != s[s.size() - 1 - i]) diffrent_exist = false;
  }
  return diffrent_exist;
}
int main( ) {
  int a,b,ans = 0;
  cin >> a >> b;
  for ( int i = a; i <= b; i++ ) {
    if (isPalindrome(i)) ans++;  
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <array>
#include <algorithm>
#include <set>

using namespace std;

#define int long long

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

    int x;

    cin >> x;

    set<char> s;

    char c;

    for (int i = 0; i < x; ++i)
    {
        cin >> c;
        s.insert(c);
    }

    cout << (s.size() == 3 ? "Three" : "Four") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char S[100005];
    int i, j;
    int including;
    scanf(" %s", &S);

    for (i = 97; i < 123; i++){
        j = 0;
        while (S[j] != 0){
            if (S[j] == i){
                including = i; 
            }
            j++;
        }
        if (including != i){
            printf("%c", i);
            return 0;
        }else if (including == 122){
            printf("None");
            return 0;
        }
    }
}

Measured memory_bytes: 256
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  char Alpha ;
  int N, ans = 0, check ;
  cin >> Alpha ;

  if(Alpha <= 'Z'){
    cout << "A" << endl ;
  }  
  else{
    cout << "a" << endl ;
  }  

  return 0 ;
}  

Measured memory_bytes: 3616
import math

L = input().split()
A = int(L[0])
B = int(L[1])
H = int(L[2])
M = int(L[3])


rad_A = H * 30 + M * 0.5
rad_B = M * 6

rad = rad_A - rad_B
if rad > 180:
    rad = 360 - rad

cos_num = math.cos(math.radians(rad))


x_squared = A**2 + B**2 - (2 * A * B * cos_num)
ans = math.sqrt(x_squared)

print(ans)

Measured memory_bytes: 9464
n = int(input())
h = list(map(int, input().split()))

h = h[::-1]

for i in range(len(h)-1):
    if h[i] < h[i+1]:
        h[i+1] -= 1
        if not  h[i] == h[i+1]:
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 14396
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var k = int.Parse(line[2]);

        var inputArray = new bool[h][];
        var ans = 0;


        for(var r = 0; r < h; r++)
        {
            var l = Console.ReadLine().ToCharArray();
            var ar = new bool[w];
            inputArray[r] = ar;
            for(var c = 0; c < w; c++)
            {
                if (l[c] == '#')
                {
                    inputArray[r][c] = true;
                }
                else
                {
                    inputArray[r][c] = false;
                }
            }
        }

        for (int x = 0; x < Math.Pow(2, h); x++)
        {
            var array = new bool[h][];
            for(var num = 0; num < h; num++)
            {
                    array[num] = inputArray[num].Clone() as bool[];
            }

            // 右からk桁目を取り出す
            for (int j = 0; j < h; j++)
            {
                var y = (x >> j) & 1;
                if (y == 1)
                {
                    for (var i = 0; i < w; i++)
                    {
                        array[j][i] = false;
                    }
                }
            }

            for (int z = 0; z < Math.Pow(2, w); z++)
            {
                var tempArray = new bool[h][];
                for (var num2 = 0; num2 < h; num2++)
                {
                    tempArray[num2] = array[num2].Clone() as bool[];
                }


                for (int i = 0; i < w; i++)
                {
                    var a = (z >> i) & 1;
                    if(a == 1)
                    {
                        for (var j = 0; j < h; j++)
                        {
                            tempArray[j][i] = false;
                        }
                    }
                }

                var black = 0;

                foreach (var row in tempArray)
                {
                    foreach (var column in row)
                    {
                        if (column)
                        {
                            black += 1;
                        }
                    }
                }

                if (black == k)
                {
                    ans += 1;
                }

            }



        }
        Console.WriteLine(ans);
        Console.ReadLine();

    }

}


Measured memory_bytes: 19604
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    const double pi = acos(-1);
    double atheta =  pi / 2 - (pi * h / 6 + pi * m / 360);
    double btheta =  pi / 2 - (pi * m / 30);

    double ax = a * cos(atheta), ay = a * sin(atheta);
    double bx = b * cos(btheta), by = b * sin(btheta);
    double ans = hypot(ax - bx, ay - by);
    cout << fixed << setprecision(15) << ans << endl;

}

Measured memory_bytes: 4116
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int x;
  cin >> x;
  rep(i, 8) {
    int j = 200 * i + 400;
    int j2 = 200 * (i+1) + 400;
    if (j <= x && x < j2) cout << 8 - i << endl; 
  }
  return 0;
}

Measured memory_bytes: 3588
import bisect
from sys import stdin
readline=stdin.readline
a,b,q=map(int,input().rstrip().split())
s=sorted([int(readline().rstrip()) for i in range(a)])
t=sorted([int(readline().rstrip()) for i in range(b)])
for i in range(q):
    ans=999999999999
    x=int(readline().rstrip())
    w=bisect.bisect_left(s,x)
    for j in range(2):
        if not 0<=w-j<len(s):
            continue
        z=bisect.bisect_left(t,s[w-j])
        for k in range(2):
            if not 0<=z-k<len(t):
                continue
            ans=min(ans,abs(x-s[w-j])+abs(s[w-j]-t[z-k]))
    w=bisect.bisect_left(t,x)
    for j in range(2):
        if not 0<=w-j<len(t):
            continue
        z=bisect.bisect_left(s,t[w-j])
        for k in range(2):
            if not 0<=z-k<len(s):
                continue
            ans=min(ans,abs(x-t[w-j])+abs(t[w-j]-s[z-k]))
    print(ans)

Measured memory_bytes: 12840
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll d[mm];
int main()
{
   ll n,m,i,j,t,a,b,c,p,k,kk; 
	cin>>a>>b>>c;
	ll s=0;
	s=a/b*c;
	if(a%b) s+=c;
	cout<<s<<endl;
} 

Measured memory_bytes: 3164
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
 
n, m, p = na()
 
def bf(es, n, start):
    d = [999999999999] * n
    d[start] = 0
 
    for r in range(n-1):
        updated = False
        for e in es:
            if d[e[0]] == 999999999999:
                continue
            if d[e[0]] + e[2] < d[e[1]]:
                d[e[1]] = d[e[0]] + e[2]
                updated = True
        if not updated:
            break
 
    for e in es:
        if d[e[0]] < 999999999999 and d[e[0]] + e[2] < d[e[1]]:
            return None
 
    return d
 
es = []
for i in range(m):
    a, b, c = na()
    es.append((a-1, b-1, -(c-p)))
 
import collections
q = collections.deque()
q.append(n-1)
 
valid = [False] * n
valid[n-1] = True
while len(q) > 0:
    cur = q.popleft()
    for e in es:
        if e[1] == cur and not valid[e[0]]:
            valid[e[0]] = True
            q.append(e[0])
 
nes = []
for e in es:
    if valid[e[0]] and valid[e[1]]:
        nes.append(e)
es = nes
 
d = bf(es, n, 0)
if not d:
    print(-1)
else:
    print(max(0, -d[n-1]))

Measured memory_bytes: 74696
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> bingo(3, vector<int>(3));
vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;

	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

ll getGcd(ll a, ll b) {
	if (a < b) {
		ll temp = b;
		b = a;
		a = temp;
	}

	ll r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}

int main() {

	double R; cin >> R;
	double ans = R * 2 * PI;
	cout << fixed << setprecision(10) << ans << endl;
}



Measured memory_bytes: 5396
//   ┏━━┓┏━━┓┏┓┏┓┏┳━┳┓┏━━┓┏━┳┓┏━━┓     ┏┳┓┏┳┓┏━┳━┓┏━━┓┏━┓
//   ┃┏┓┃┃━━┫┃┗┛┃┃┃┃┃┃┃┏┓┃┃┃┃┃┗┃┃┛     ┃┏┛┃┃┃┃┃┃┃┃┃┏┓┃┃╋┃
//   ┃┣┫┃┣━━┃┃┏┓┃┃┃┃┃┃┃┣┫┃┃┃┃┃┏┃┃┓     ┃┗┓┃┃┃┃┃┃┃┃┃┣┫┃┃┓┫
//   ┗┛┗┛┗━━┛┗┛┗┛┗━┻━┛┗┛┗┛┗┻━┛┗━━┛     ┗┻┛┗━┛┗┻━┻┛┗┛┗┛┗┻┛
#include<bits/stdc++.h>
using namespace std;
int findNumberOfTriangles(int arr[], int n) 
{ 
    // Count of triangles 
    int count = 0; 
  
    // The three loops select three 
    // different values from array 
    for (int i = 0; i < n; i++) { 
        for (int j = i + 1; j < n; j++) { 
  
            // The innermost loop checks for 
            // the triangle property 
            for (int k = j + 1; k < n; k++) 
  
                // Sum of two sides is greater 
                // than the third 
                if ( 
                    arr[i] + arr[j] > arr[k] 
                    && arr[i] + arr[k] > arr[j] 
                    && arr[k] + arr[j] > arr[i] && arr[i]!=arr[j] && arr[j]!=arr[k] && arr[i]!=arr[k]) 
                    count++; 
        } 
    } 
    return count; 
} 

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++){
      cin>>a[i];
    }
    cout<<findNumberOfTriangles(a, n); 
  

  return 0;
}
// By Ashwani Kumar, Indian Institute Of Technology(IIT), Guwahati.
//   ╔══╗╔══╗╔══╗     ╔══╗╔╦╗╔╦═╦╗╔══╗╔╗╔╗╔══╗╔══╗╔══╗
//   ╚║║╝╚║║╝╚╗╔╝     ║╔═╣║║║║║║║║║╔╗║║╚╝║║╔╗║╚╗╔╝╚║║╝
//   ╔║║╗╔║║╗─║║─     ║╚╗║║║║║║║║║║╠╣║║╔╗║║╠╣║─║║─╔║║╗
//   ╚══╝╚══╝─╚╝─     ╚══╝╚═╝╚═╩═╝╚╝╚╝╚╝╚╝╚╝╚╝─╚╝─╚══╝


Measured memory_bytes: 3532
import Text.Printf
body :: Int -> IO ()
body i = do
         ln <- getLine
         let [x,y] = map read $ words ln :: [Int]
         if (x == 0 && y == 0) then return () else do
           printf "%d %d\n" (if (x < y) then x else y) (if (x < y) then y else x)
           body (i + 1)

main = body 1

Measured memory_bytes: 4260
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>n;
    rep(i,n)cin>>a[i];
    ans=0;
    rep(i,n){
        ans=(ans xor a[i]);
    }
    rep(i,n){
        if((ans xor a[i]) != a[i]){
            Cout("No");
            return 0;
        }
    }
    Cout("Yes");
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
using namespace std;

const double eps = 1e-10;
int K, R, L;
double P, E, T;

bool equals(double a, double b) {
  return fabs(a-b) < eps;
}

double rec(double r, double l, int k) {
  double h = (r+l)/2;
  if(k == K)
    return (fabs(T-h) < E || equals(fabs(T-h), E)) ? 1.0 : 0.0;

  if((fabs(T-r) < E || equals(fabs(T-r), E)) &&
     (fabs(T-l) < E || equals(fabs(T-l), E))) return 1.0;
  if(r-T > E || equals(r-T, E)) return 0.0;
  if(T-l > E || equals(T-l, E)) return 0.0;

  if(h > T || equals(h, T)) {
    return rec(r, h, k+1)*(1-P) + rec(h, l, k+1)*P;
  } else {
    return rec(h, l, k+1)*(1-P) + rec(r, h, k+1)*P;
  }
}

int main() {
  cin >> K >> R >> L;
  cin >> P;
  cin >> E;
  cin >> T;
  printf("%.12f\n", rec(R, L, 0));
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl p(n);
  rep(i,n){
    cin >> p[i];
    p[i]--;
  }
  ll ans=0;
  rep(i,n){
    if(p[i]==i){
      if(p[i+1]==i+1){
        i++;
      }
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
N=list(map(int,input().split()))
m=int(N[0])
n=int(N[1])
ans=1
while(ans!=0):
    ans=m%n
    if(ans<n and ans!=0):
        m=n
        n=ans
    else:
        pass
print(int((N[0]*N[1])/n))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,min_num=10000000,max_num=-10000000;
    long long sum=0;
    cin >> n;
    int i,tmp;
    for(i=0;i<n;i++){
        cin >> tmp;
        min_num=min(min_num,tmp);
        max_num=max(max_num,tmp);
        sum+=tmp;
    }
  cout << min_num <<  " " << max_num << " " << sum << endl;
  return 0;
}


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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int w, h;
    cin >> w >> h;
    vector<int> n_cc;
    while(w != 0 && h != 0){
        vector<vector<int>> c(h+2, vector<int>(w+2, 0));
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                cin >> c[i][j];
            }
        }

        int visited[h+2][w+2] = {0};
        stack<pair<int, int>> stk;
        int cc = 0;
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                if(c[i][j] == 0 || visited[i][j] == 1) continue;
                visited[i][j] = 1;
                stk.push(make_pair(i, j));
                while(!stk.empty()){
                    int i0 = stk.top().first, j0 = stk.top().second;
                    stk.pop();
                    for(int id=-1; id<=1; id++){
                        for(int jd=-1; jd<=1; jd++){
                            if(c[i0+id][j0+jd] == 1 && visited[i0+id][j0+jd] == 0){
                                visited[i0+id][j0+jd] = 1;
                                stk.push(make_pair(i0+id, j0+jd));
                            }
                        }
                    }
                }

                cc++;
            }
        }
        n_cc.push_back(cc);

        cin >> w >> h;
    }

    for(int i=0; i<n_cc.size(); i++){
        cout << n_cc[i] << endl;
    }

    return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    // P(b,a)
    vector< P > req(M);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        req[i] = P(b, a);
    }
    sort(req.begin(), req.end());

    int ans = 1;
    int curr = req[0].first;
    for (int i = 1; i < M; i++) {
        if (req[i].second < curr && curr <= req[i].first) {
            continue;
        }
        ++ans;
        curr = req[i].first;
    }
    cout << ans << endl;
}

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint extgcd(llint a,llint b,llint &x,llint &y){
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    llint d = extgcd(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

void solve(){
    int a,b;
    cin >> a >> b;
    llint x,y;
    extgcd(a,b,x,y);
    cout << x << " " << y << endl;
}

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



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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

// NodePointer listSearch(int key){
//   /* your code */
// }

void init(){
//   nil = malloc(sizeof(struct node));
  nil = (node*)malloc(sizeof(node));
  nil->next = nil;
  nil->prev = nil;
}

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

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
  // t->prev = nil;
  // t->next = nil;
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteKey(int keyvalue){
  NodePointer t = nil->next;
  while(1){
      if ( t == nil ) return;

      if(t->key == keyvalue){
        deleteNode(t);
        break;
      }else{
        t = t->next;
      }
  }
  // return;
}


void insert(int key){
  NodePointer x;
//   x = malloc(sizeof(struct node));
  x = (node*)malloc(sizeof(node));
  x->key = key;
  x->prev = nil;
  x->next = nil->next;
  nil->next->prev = x; //これが全然わからなかった！
  nil->next = x;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {
      insert(key); 
      np++; 
      size++;
    }else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ){
          // printf("key : %d", key); 
          deleteFirst();
        }else if ( com[6] == 'L' ){
          deleteLast();
        }
      }else{
	      deleteKey(key); nd++;
      }
      size--;
      }
    }

  printList();
  return 0;
}


Measured memory_bytes: 34388
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		long n = scn.nextLong();
		long i = 1;
       	long j = 1;
      	long a = 1;
      while(a<=n/a){
        if(n%a==0){
          i = a;
          j = n/i;
        }
        a++;
      }
      System.out.println(i+j-2);
	}
}


Measured memory_bytes: 35764
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	ll d, t, s;
	cin >> d >> t >> s;
	cout << (s * t >= d? "Yes": "No") << '\n';
}



Measured memory_bytes: 3656
# -*- coding: utf-8 -*-
import sys
import heapq
INF = 10**20

N,M,S = map(int,input().split())
UVAB = [list(map(int,input().split())) for _ in range(M)]
CD = [list(map(int,input().split())) for _ in range(N)]
#%%
def ic(i,c):
    # i番目の都市で，所持金cの頂点
    return i+c*50


MAX_S = 0
for _,_,a,_ in UVAB:
    MAX_S = max(MAX_S, a)
MAX_S *= N
S = min(S, MAX_S)
MAX_N = ic(N-1, MAX_S) + 1
edge = [[] for _ in range(MAX_N)]

for u,v,a,b in UVAB:
    # 所持金c -> c-aに辺を張る    
    for c in range(a,MAX_S+1):
        edge[ic(u-1,c)].append([ic(v-1,c-a),b])
        edge[ic(v-1,c)].append([ic(u-1,c-a),b])

for i in range(N):
    # 各頂点に所持金 c -> c+Ciの辺を張る
    ci = CD[i][0]
    di = CD[i][1]
    for c in range(MAX_S):
        edge[ic(i,c)].append([ic(i,min(c+ci,MAX_S)),di])



def dijkstra(S, N, Edge):
    # S: start vertex
    # N: number of vertices
    # Edge: adjacent list [node, cost]
    
    INF = 10**20
    dist = [INF]*N
    dist[S] = 0
    que = [[0, S]]
    heapq.heapify(que)
    
    while que:
        c, v = heapq.heappop(que)
        if dist[v] < c: continue

        for nv, nc in Edge[v]:
            if c+nc < dist[nv]:
                dist[nv] = c+nc
                heapq.heappush(que, [c+nc, nv])
    
    return dist

dist = dijkstra(ic(0, S), MAX_N, edge)
for i in range(1,N):
    ans = INF
    for c in range(MAX_S):
        ans = min(ans, dist[ic(i,c)])
    print(ans)
                
            
        
    
    
    
    
    
        
    
    

    
    





Measured memory_bytes: 160044
int power(long long x, unsigned int y, int p )
{
	int ans=1;
	x=x%p;
	if(x==0) return 0;

	while(y>0)
	{
		if(y%2)
			ans=(ans*x)%p;
	
		y=y/2;
		x=(x*x)%p;
	}
	return ans;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
 	int n;
  cin>>n;
  int x=1000000007;
  long a=((power(10,n,x)%x-(2%x)*(power(9,n,x))%x)+x)%x;
  long b=(a%x+1ll*power(8,n,x)%x)%x;
  cout<<b;
return 0;
}

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

int n;
string a, b, c;

void solve(){
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(a[i] == b[i] && b[i] == c[i]) continue;
    else if(a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) ans++;
    else ans += 2;
  }
  cout << ans << endl;
}

int main(){
  cin >> n >> a >> b >> c;
  solve();
  return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define mod(i) (i)%2
#define INF (1e9)

using namespace std;

int main()
{
    int H,N,A[10010],B[10010],dp[2][10010];
    //dp[mod(i)][h]:i番目までの魔法を使ってh以上のダメージ与えるのにかかる最小魔力
    //memset(dp,0,sizeof(dp));
    rep(i,2){rep(h,10010){dp[i][h]=INF;}}
    dp[0][0]=0;
    dp[1][0]=0;
    cin>>H>>N;
    rep(i,N){
        cin>>A[i]>>B[i];
    }

    //dp
    rep(i,N){
        rep(h,H+1){
            if(h>=A[i]){
                dp[mod(i+1)][h] = min(dp[mod(i)][h], dp[mod(i+1)][h-A[i]]+B[i]);
            }else{
                dp[mod(i+1)][h] = min(dp[mod(i)][h],B[i]);
            }
        }
    }

    cout << dp[mod(N)][H] << endl;
    
    return 0;
}

Measured memory_bytes: 3696
# xとyどっちを優先にするか
# -> これだとなんかできそうでできない ABピザとハイブリッドしたほうが得な場合もありそう（多分
# 「ABピザをいくつ使うか」固定して全探索してみる

a, b, c, x, y = map(int, input().split())
ans = 10**18
for i in range(2 * 10**5 + 100):
    # ABピザi枚使ったとする（奇数枚はありえないので2倍
    p = 2 * c * i + a * (max(0, x - i)) + b * (max(0, y - i))
    # print(f"ABピザを{2*i}枚使ったよ p={p}")
    ans = min(ans, p)
print(ans)

Measured memory_bytes: 9176
import java.util.Scanner;
public class Main {
	Scanner sc = new Scanner(System.in);
	int x,y;	
	int keep=0;
	
	public void input() {
		x = sc.nextInt();
		y = sc.nextInt();
	}
	
	public void conpute() {
		if(x > y) {
			while(x%y != 0) {
				keep = x;
				x = y;
				y = keep % y;
			}
			System.out.println(y);
		}else {
			while(y%x != 0) {
				keep = y;
				y = x;
				x = keep % y;
			}
			System.out.println(x);
		}
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.conpute();
	}
}



Measured memory_bytes: 26308
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<map> 
using namespace std;
 
const int N=4005;
 
int n,x,y,ans,inf;
int a[N],dp[N][N],f[N][N],g[N][N],h[N];
char c[N],s[N];

void add(int x,int w){
	for (;x<=n;x+=x&-x) h[x]+=w;
}

int query(int x){
	int s=0;
	for (;x;x-=x&-x) s+=h[x];
	return s;
}

void init(){
	int i,j,k;
	for (i=0;i<=n;i++){
		k=0;
		memset(h,0,sizeof(h));
		for (j=1;j<=n+n;j++){
			if (c[j]=='W'){
				f[i][a[j]]=k-query(a[j]);
				add(a[j],1);
			}
			k++;
			if (c[j]=='B'&&a[j]<=i) k--;
		}
	}
	for (i=0;i<=n;i++){
		k=0;
		memset(h,0,sizeof(h));
		for (j=1;j<=n+n;j++){
			if (c[j]=='B'){
				g[i][a[j]]=k-query(a[j]);
				add(a[j],1);
			}
			k++;
			if (c[j]=='W'&&a[j]<=i) k--;
		}
	}
}

int main(){
	int i,j;
	scanf("%d",&n);
	memset(dp,0x3f,sizeof(dp));
	inf=dp[0][0];
	for (i=1;i<=n+n;i++){
		scanf("%s",s);
		scanf("%d",&a[i]);
		c[i]=s[0];
	}
	x=y=0; dp[0][0]=0;
	init();
	for (i=0;i<=n;i++)
		for (j=0;j<=n;j++) if (dp[i][j]<inf){
			if (i<n) dp[i+1][j]=min(dp[i+1][j],dp[i][j]+g[j][i+1]);
			if (j<n) dp[i][j+1]=min(dp[i][j+1],dp[i][j]+f[i][j+1]);
		} 
	ans=dp[n][n];
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  int count = 0;
  int digs[5]; 
  int copy;
  
  for (int i = A; i <= B; i++) {
    copy = i;
    digs[0] = copy % 10;
    copy /= 10;
    digs[1] = copy % 10;
    copy /= 10;
    digs[2] = copy % 10;
    copy /= 10;
    digs[3] = copy % 10;
    copy /= 10;
    digs[4] = copy % 10;
    
    if (digs[0] == digs[4] && digs[1] == digs[3]) count++;
  }
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    string s; cin >> s;
    map<char, ll> m;
    for(char c : s) m[c]++;
    if(m.size() < 3) {
        if(m.size() == s.size()) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    else {
        for(auto a : m) if(a.second < s.size() / 3 || s.size() / 3 + 1 < a.second) {
            cout << "NO" << endl;
            return 0;
        }
        cout << "YES" << endl;
    }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int N,D,X;
  cin >> N >> D >> X;
  int ans = X;
  REP(i,N){
    int a;
    cin >> a;
    ans += (D-1)/a+1;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<cmath>

using namespace std;

int main(){
	int e,m;
	
	while(cin>>e,e){
		m=INT_MAX;
		for(int z=0;z<=100;z++){
			int xy2=e-pow((double)z,3.0);
			if(xy2<0){
				break;
			}
			for(int y=0;pow((double)y,2.0)<=xy2;y++){
				int x=xy2-pow((double)y,2.0);
				m=min(m,x+y+z);
			}
		}
		cout<<m<<endl;
	}
}

Measured memory_bytes: 1224
import java.util.*;
  public class Main {
      public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
		sc.close();
		String red = "red";
		if(a<3200){
			System.out.println(red);
		}else{
			System.out.println(s);
		}
      }
  }

Measured memory_bytes: 21716
group1=[1,3,5,7,8,10,12]
group2=[4,6,9,11]
group3=[2]
a,b=map(int,input().split())
if(a==2 and b==2):
  print('Yes')
elif(((a in group1) and (b in group1)) or ((a in group2) and (b in group2))):
  print('Yes')
else:print('No')

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            if (firstWins(a)) {
                out.println("First");
            } else {
                out.println("Second");
            }
        }

        private boolean firstWins(int[] a) {
            long s = 0;
            for (int b : a) s += b - 1;
            if (s % 2 != 0) {
                return true;
            }
            int oddPos = -1;
            for (int i = 0; i < a.length; ++i) {
                if (a[i] % 2 != 0) {
                    if (oddPos >= 0) return false;
                    oddPos = i;
                }
            }
            if (oddPos < 0) throw new RuntimeException();
            if (a[oddPos] == 1) return false;
            --a[oddPos];
            int g = 0;
            for (int x : a) g = gcd(g, x);
            if (g == 1) throw new RuntimeException();
            for (int i = 0; i < a.length; ++i) {
                a[i] /= g;
            }
            return !firstWins(a);
        }

        private int gcd(int a, int b) {
            while (b > 0) {
                int t = a % b;
                a = b;
                b = t;
            }
            return a;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 24280
C = [list(map(int,input().split())) for _ in range(3)]
for i in range(max(C[0])+1):
  flg = True
  a1 = i
  b1 = C[0][0] - a1
  b2 = C[0][1] - a1
  b3 = C[0][2] - a1
  a2 = C[1][0] - b1
  a3 = C[2][0] - b1
  if a2 + b2 != C[1][1] or a2 + b3 != C[1][2] or a3 + b2 != C[2][1] or a3 + b3 != C[2][2]:
    flg = False
  if flg == True:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 3188
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)


int h, w, d;
string s = "RYGB";
int main() {
	cin >> h >> w >> d;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int x = (10101010+(i + j))/ d % 2;
			int y = (10101010+(i - j))/ d % 2;
			cout << s[x * 2 + y];
		}
		cout << endl;
	}
}

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

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;
const int N = 2e5 + 10;
int fact[N];
int factInv[N];
int inv[N];

int mul(int a, int b)
{
  a = (a + mod) % mod;
  b = (b + mod) % mod;
  return ((ll)a * b) % mod;
}

int add(int a, int b)
{
  a = (a + mod) % mod;
  b = (b + mod) % mod;
  return (a + b) % mod;
}

int fastpow(int base, int power)
{
  if(!power)
    return 1;
  int ret = fastpow(base, power / 2);
  ret = mul(ret, ret);
  if(power & 1)
    ret = mul(ret, base);
  return ret;
}

void init()
{
  fact[0] = 1;
  for(int i = 1; i < N; i++)
    fact[i] = mul(fact[i - 1], i);
  inv[1] = 1;
  for(int i = 2; i < N; i++)
    inv[i] = mul(-mod / i, inv[mod % i]);
  factInv[1] = factInv[0] = 1;
  for(int i = 2; i < N; i++){
     factInv[i] = mul(factInv[i - 1], inv[i]);
   }
}

int ncr(int n, int r)
{
  return mul(fact[n], mul(factInv[r], factInv[n - r]));
}

int ways(int x1, int y1, int x2, int y2)
{
  int n = (x2 - x1);
  int m = (y2 - y1);
  return ncr(n + m, n);
}

int h, w;
int n;
vector<pair<int, int>> obs;
int dp[3005][3005];

int main()
{
  init();
  cin >> h >> w >> n;
  for(int i = 0; i < n; i++)
  {
    int x, y;
    cin >> x >> y;
    obs.push_back({x, y});
  }
  sort(obs.begin(), obs.end());
  int ans = ways(1, 1, h, w);
  for(int i = 0; i < n; i++)
  {
    dp[n][i] = add(-ways(obs[i].first, obs[i].second, h, w), 0);
  }
  for(int i = n - 1; i >= 0; i--)
  {
    for(int j = 0; j < i; j++)
    {
      dp[i][j] = dp[i + 1][j];
      if(obs[i].second >= obs[j].second)
      {
        dp[i][j] = add(dp[i][j], mul(-ways(obs[j].first, obs[j].second, obs[i].first, obs[i].second)
                               , dp[i + 1][i]));
      }
    }
  }
  for(int i = 0; i < n; i++)
  {
    ans = add(ans, mul(ways(1, 1, obs[i].first, obs[i].second), dp[i + 1][i]));
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 36608
gets
ap=am=tp=tm=0
sp=true
gets.split.map(&:to_i).each{|e|
  tp+=e
  tm+=e
  if sp
    if tp<=0
      ap+=-tp+1
      tp=1
    end
    if tm>=0
      am+=tm+1
      tm=-1
    end
  else
    if tp>=0
      ap+=tp+1
      tp=-1
    end
    if tm<=0
      am+=-tm+1
      tm=1
    end
  end
  sp = !sp
}
p [ap,am].min


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,m;
    cin >> n >> m;
    vector<vector<int32>> d(n, vector<int32>(n, INF));
    REP(i,m){
        int32 a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        d[a][b] = d[b][a] = c;
    }
    vector<vector<int32>> next(n, vector<int32>(n));
    REP(i,n)REP(j,n)next[i][j] = j;
    REP(k,n)REP(i,n)REP(j,n){
        if(d[i][j] > d[i][k] + d[k][j]){
            d[i][j] = d[i][k] + d[k][j];
            next[i][j] = next[i][k];
        }
    }
    vector<vector<bool>> used(n, vector<bool>(n, false));
    REP(start,n-1)FOR(goal,start+1,n){
        for(int32 cur = start; cur != goal; cur = next[cur][goal]){
            int32 n = next[cur][goal];
            used[cur][n] = used[n][cur] = true;
        }
    }
    int32 cnt = 0;
    REP(i,n)REP(j,n){
        if(used[i][j])cnt++;
    }
    cout << m - cnt / 2 << endl;
    return 0;
}

Measured memory_bytes: 384