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

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

    int n;
    cin >> n;

    vector<int> money;
    money.push_back(1);
    int p = 6;
    for(int i=0; p<=n; i++){
        money.push_back(p);
        p *= 6;
    }
    p = 9;
    for(int i=0; p<=n; i++){
        money.push_back(p);
        p *= 9;
    }
    sort(money.begin(), money.end());

    int INF = (1LL<<40);
    vector<int> dp(n+1, INF);
    dp[0] = 0;
    for(int i=0; i<money.size(); i++){
        for(int j=0; j+money[i]<=n; j++){
            dp[j+money[i]] = min(dp[j] + 1, dp[j+money[i]]);
        }
    }
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 3976
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 12345678901234567

const int maxn = 1e5 + 10;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	
	int n; cin >> n;

	ll ans = 1;

	FOR(i, 1, n+1)ans = (ans*i) % mod;
	Print(ans);
	// your code finished
	return 0;

}

Measured memory_bytes: 256
S = input()
T1 = len(S)*"01"
T2 = len(S)*"10"
ans = []
dif = 0

for s,t in zip(S,T1):
  if s!=t:
    dif+=1

ans+=[dif]
dif = 0

for s,t in zip(S,T2):
  if s!=t:
    dif+=1

ans+=[dif]
print(min(ans))

Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


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

	ll N,K;
	cin >> N >> K;
	ll dp[N+3];
	FOR(i,0,N+3)dp[i]=INF;
	ll h[N+3];
	FOR(i,1,N+1)cin>>h[i];
	dp[1] = 0;
	FOR(i,1,N+1){
		FOR(j,1,K+1){
			if(i+j<=N)dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
		}
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 1792
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  //tmp = input[0].split(" ");
  //文字列から10進数に変換するときはparseIntを使います
  var X = input[0] - 0;
  var answer = X;
  while(true){
    var findAns = true;
    base = Math.floor(Math.sqrt(answer));
    for(var i=2; i<=base; i++){
      if(answer % i == 0){
        findAns = false;
        break;
      }
    }
    if(findAns){
      
      break;
    }else{
      answer++;
    }
  }
  //出力
  console.log(answer);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt()
    val k = sc.nextInt()
    var c = 0
    var x = 0
    var a:Double = (1.toDouble/n.toDouble)
    var r:Double = (1.toDouble/2.toDouble)
    val y = new Array[Double](n)

    for(i <- 1 to n) {
      x = i
      c = 0
      while(x < k) {
        x *= 2
        c += 1
      }
      y(i - 1) = a * Math.pow(r, c)
    }
    println(y.sum)
  }

}


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

ans=0
for i in range(n):
    tmp=0
    j=0
    while j<=i:
        tmp+=a[j]
        j+=1
    while j<=n:
        tmp+=a2[j-1]
        j+=1
    if tmp>ans:
        ans=tmp
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
ll uni[1000000];
ll root(ll u){
    if(uni[u]<0)return u;
    return uni[u]=root(uni[u]);
}

void connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return;
    if(uni[a]<uni[b]){
        a^=b;
        b^=a;
        a^=b;
    }
    uni[a]+=uni[b];
    uni[b]=a;
    return;
}
ll size(ll u){
    return -uni[root(u)];
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    memset(uni,-1,sizeof(uni));
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll m=t.length();
    while(n<m)n*=2,s+=s;
    t+="#"+s+s;
    int i = 1, j = 0;
    vector<int> Z(t.size());
    Z[0] = t.size();
    while(i < t.size()){
        while(i + j < t.size() && t[j] == t[i + j]) j++;
        Z[i] = j;
        if(j == 0){i++;continue;}
        int k = 1;
        while(i + k < t.size() && k + Z[k] < j){
            Z[i + k] = Z[k];
            k++;
        }
        i += k;j -= k;
    }
    ll len=n+1+m;
    bool maki[n],niko=false;
    memset(maki,0,sizeof(maki));
    for(int k=m+1;k<len;k++){
    	if(Z[k]==m)maki[k-(m+1)]=true,niko=true;
    }
    if(!niko){
    	cout << 0 << endl;
    	return 0;
    }

    for(int k=0;k<n;k++){
    	int num=(k+m)%n;
    	if(maki[k]&&maki[num]){
    		if(root(k)==root(num)){
    			cout << -1 <<endl;
    			return 0;
    		}
    		connect(k,num);
    	}
    }
    ll ans=0;
    for(int i=0;i<n;i++){
    	ans=max(ans,size(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 26700
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int d;
  cin >> d;
  string ans = "Christmas";
  if(d == 24) {
    ans += " Eve";
  }
  if(d == 23) {
    ans += " Eve Eve";
  }
  if(d == 22) {
    ans += " Eve Eve Eve";
  }
  cout << ans << endl;
}

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

using namespace std;


struct SegmentTree
{
  vector< pair< int, int > > lazy;
  int sz, timestamp;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    lazy.assign(2 * sz - 1, {-1, 2147483647});
    timestamp = 0;
  }

  void update(int a, int b, int x, int k, int l, int r)
  {
    if(a >= r || b <= l) {

    } else if(a <= l && r <= b) {
      lazy[k] = {timestamp, x};
    } else {
      update(a, b, x, 2 * k + 1, l, (l + r) >> 1);
      update(a, b, x, 2 * k + 2, (l + r) >> 1, r);
    }
  }

  void update(int a, int b, int x)
  {
    update(a, b, x, 0, 0, sz);
    ++timestamp;
  }

  int query(int k)
  {
    k += sz - 1;
    auto ret = lazy[k];
    while(k > 0) {
      k = (k - 1) >> 1;
      ret = max(ret, lazy[k]);
    }
    return (ret.second);
  }
};

int main()
{
  int N, Q;
  scanf("%d %d", &N, &Q);
  SegmentTree tree(N);
  while(Q--) {
    int t;
    scanf("%d", &t);
    if(t == 0) {
      int s, t, x;
      scanf("%d %d %d", &s, &t, &x);
      tree.update(s, ++t, x);
    } else {
      int i;
      scanf("%d", &i);
      printf("%d\n", tree.query(i));
    }
  }
}

Measured memory_bytes: 4892
import java.util.*;
import java.io.*;

public class Main{
 public static void main(String[] args) throws IOException
 {
   Scanner sc = new Scanner(System.in);
   InputStreamReader is = new InputStreamReader(System.in);
   BufferedReader br = new BufferedReader(is);
   
   String inStr = br.readLine();
   double r = Double.parseDouble(inStr);
 
    System.out.printf("%.6f", r*r*Math.PI);
    System.out.print(" ");
    System.out.printf("%.6f", 2*r*Math.PI);
    System.out.println("");
 }
}

Measured memory_bytes: 26444
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b = sc.nextInt(),c = sc.nextInt();
        System.out.println((a < b && b < c) ? "Yes" : "No");
        sc.close();
    }

}

Measured memory_bytes: 25996
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int c[101000],ok[10000000];
int h[101000],nxt[201000],K=0,to[201000],cost[201000];int cnt[16],ans=0;
void ins(int u,int v,int c){nxt[++K]=h[u];h[u]=K;to[K]=v;cost[K]=c;}
void dfs(int x,int f,int val)
{
	int k=0;
	for(int i=h[x];i;i=nxt[i])
	{
		if(to[i]==f)continue;
		k^=cost[i];dfs(to[i],x,cost[i]);
	}
	if(x)cnt[val^k]++;
}
int a[18],tot=0,dp[1<<15];
int DP(int S)
{
	
	if(dp[S]!=-1)return dp[S];dp[S]=2000000000;
	for(int i=0;i<15;i++)
	for(int j=i+1;j<15;j++)
	{
		if(((S>>i)&1)&&((S>>j)&1))
		{
			int k=(i+1)^(j+1);
			dp[S]=min(dp[S],DP(S^(1<<(k-1))^(1<<j)^(1<<i))+1+(((S>>(k-1))&1)?1:0));
		}
	}
	for(int i=0;i<15;i++)
		if((S>>i)&1)
			dp[S]=min(dp[S],DP(S^(1<<i))+1);
	return dp[S];
}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<n;i++){int x,y,c;scanf("%d%d%d",&x,&y,&c);ins(x,y,c);ins(y,x,c);}
	dfs(0,-1,0);
	int S=0;
	for(int i=1;i<=15;i++)
	{
		ans+=cnt[i]/2;
		if(cnt[i]&1)S|=1<<(i-1);
	}
	memset(dp,-1,sizeof(dp));dp[0]=0;
	printf("%d",DP(S)+ans);
	return 0;
}

Measured memory_bytes: 8832
#include <stdio.h>

int main(){

    int x,y;
    
    while (1)
    {
        scanf("%d%d",&x,&y);
        if (x==0&&y==0)
            break;
        if (x>y){
                printf("%d %d\n",y,x);
        }
else{
                printf("%d %d\n",x,y);
    }}

    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b) {
    if(b == c) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  else if(b == c) {
    if(c == a) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  else if(c == a) {
    if(a == b) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 100110;
int main(){

    while(1){        
        int n; cin >> n;
        if(!n) break;
        vector<int> a(n);
        for(int i = 0; i < n; i++) scanf("%d", &a[i]);

        //i番目までの品物を見て、持ってる小銭がj円の時の{500玉の個数、-消費金額}のmax
        vector<vector<pair<int, int> > > dp(n + 1, vector<pair<int, int> > (500 * n + 1000, {-INF, -INF}));
        //vector<vector<vector<int> > > dp(2, vector<vector<int> > (n + 1, vector<int> (500 * n + 1000, INF)));  
        dp[0][0] = {0, 0};
        pair<int, int> ans = {0, 0};
        for(int i = 0; i < n; i++){
            for(int j = 0; j <= 500 * n; j++){

                if(dp[i][j].first == -INF || dp[i][j].second == -INF) continue;
                //cout << i << " " << j << " " << dp[i][j].first << " " << dp[i][j].second << endl;

                //買わない
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

                //買うんだけども、これに場合分けが生じる
                int r = a[i] % 1000;
                //cout << r << endl;
                if(1 <= r && r <= 500){
                    //1000札のみで払い、お釣りを受け取るのが最適で、500円玉1枚加算される
                    pair<int, int> next = dp[i][j];
                    next.first++;
                    next.second -= a[i];
                    dp[i + 1][j + 500 - r] = max(dp[i + 1][j + 500 - r], next);
                }else if(r == 0){
                    //小銭があるのなら、500円玉に両替する感覚が適切な可能性あり
                    //cout << "ok" << endl;
                    pair<int, int> next = dp[i][j];
                    next.first++;
                    next.second -= a[i];
                    if(j - 500 >= 0) dp[i + 1][j - 500] = max(dp[i + 1][j - 500], next);
                }else{
                    pair<int, int> next = dp[i][j];
                    next.second -= a[i];
                    //cout << "ok" << endl;
                    //1000札のみを用いて、小銭を増やす作戦
                    dp[i + 1][j + 1000 - r] = max(dp[i + 1][j + 1000 - r], next);
                    //cout << dp[i + 1][j + 1000 - r].first << " " << dp[i + 1][j + 1000 - r].second << endl;
                    //小銭を駆使して、500円玉を入手
                    next.first++;
                    if(j - r + 500 >= 0) dp[i + 1][j - r + 500] = max(dp[i + 1][j - r + 500], next);
                    //cout << dp[i + 1][j + r - 500].first << " " << dp[i + 1][j + 1000 - r].second << endl;
                    
                }

                
            }
        }

        for(int j = 0; j < 500 * n + 1000; j++) ans = max(ans, dp[n][j]);
        //cout << dp[1][0].first << " " << dp[1][0].second << endl;
        cout << ans.first << " " << -ans.second << endl;
        
    }
    return 0;
}


Measured memory_bytes: 43792
n=int(input())
l=list(input())
q=int(input())
bit=[[0]*(n+1) for i in range(26)]
def bit_sum(o,i):
  s=0
  while i:
    s+=bit[o][i]
    i-=i&-i
  return s
def bit_add(o,i,x):
  while i<=n:
    bit[o][i] += x
    i+=i&-i
for i in range(n):
  bit_add(ord(l[i])-97,i+1,1)
for i in range(q):
  a,b,c=input().split()
  b=int(b)-1
  if a=='1':
    bit_add(ord(l[b])-97,b+1,-1)
    l[b]=c
    bit_add(ord(c)-97,b+1,1)
  else:
    c=int(c)
    print(sum(1 for o in range(26) if bit_sum(o,c)-bit_sum(o,b)))

Measured memory_bytes: 172060
#include <cstdio>
#include <queue>
#include <algorithm>

using namespace std;

const int NMAX = 800;

char a[NMAX+5][NMAX+5];
bool vis[NMAX+5][NMAX+5];
queue <pair <int, int> > q;

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

inline int myabs(int x)
{
    return x > 0 ? x : -x;
}


int main()
{
    //freopen("test.in", "r", stdin);
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    for(int i=0; i<n; i++)
        scanf("%s", a[i]);
    pair <int, int> start;
    for(int i=0; i<n; i++)
        for(int j=0; j<m; j++)
            if(a[i][j] == 'S')
            {
                start = pair <int, int> (i, j);
                q.push(pair <int, int> (i, j));
                vis[i][j] = true;
            }
    int Min = (1LL<<31)-1;
    while(!q.empty())
    {
        pair <int, int> top = q.front();
        q.pop();
        Min = min(Min, top.first);
        Min = min(Min, top.second);
        Min = min(Min, n-1-top.first);
        Min = min(Min, m-1-top.second);
        for(int i=0; i<4; i++)
        {
            pair <int, int> New = pair <int, int> (top.first+dx[i], top.second+dy[i]);
            if(myabs(New.first - start.first) + myabs(New.second - start.second) <= k)
            if(New.first>=0 && New.second>=0 && New.first<n && New.second<m && vis[New.first][New.second]==0)
            if(a[New.first][New.second] == '.')
            {
                vis[New.first][New.second] = true;
                q.push(New);
            }
        }
    }
    if(Min == 0) printf("1\n");
    else printf("%d\n", 2+(Min-1)/k);
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define all(x) (x).begin(), (x).end()

#ifdef LOCAL
#define dbg(x) cerr << #x " = " << x << endl;
#define idbg(x) #x " = " << x
#include "pretty_print.h"
#else
#define dbg(x)
#define idbg(x) ""
#endif

#ifdef _WIN32
#  define LLD "%I64d"
#else
#  define LLD "%lld"
#endif

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }


int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif

    int d;
    string s;
    while (cin >> d >> s) {
        for (auto& c : s) {
            c = ((c - 'A') + d) % 26 + 'A';
        }
        cout << s << "\n";
    }


    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


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

using namespace std;

int main() {
  string s;
  string t;
  cin >> s >> t;
  int count = 0;
  for (int i = 0; i < 3; ++i) {
    if (s[i] == t[i]) count++;
  }
  cout << count << endl;
}

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

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double c = 0.0;
  const double PI=3.14159265358979323846;
  c = A*A + B*B - 2*A*B*cos(H*PI/6 + M*PI/360- M*PI/30);
  c = sqrt(c);
  
  cout << std::fixed << std::setprecision(15) << c << endl;
}

Measured memory_bytes: 4188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 1; i < (n)+1; i++) 
#define out(n) cout << n << endl;
static const double pi = 3.141592653589793;

int main() {
  unsigned long long a, ans;
  long double b;

  cin >> a >> b;

  ans = a*b;

  out(ans);
}

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

int main() {
  int n;

  cin >> n;

  vector<int> a(n,0);

  for(int i=1;i*i<n;i++) {
    int ii=i*i;
    for(int j=1;j*j<n;j++) {
      int jj=j*j;
      if(ii+jj>=n) continue;
      for(int k=1;k*k<n;k++) {
        int kk=k*k;
        int num=ii+jj+kk+i*j+j*k+k*i;
        if(num>n) break;
        a[num-1]++;
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 3604
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
long long i,j,k,m,n,s,x,y,z,a[20][20],b[20][20];
double p;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(;i++<n;)
	{
		cin>>p;
		p=p*1000000000+0.01;
		m=(long long)p;
		if(m)
		{
			for(x=0;m%2<1;m/=2)x++;
			for(y=0;m%5<1;m/=5)y++;
			x=min(x,18LL);
			y=min(y,18LL);
			a[x][y]++;
			b[x][y]++;
		}
		else a[18][18]++;
	}
	for(i=19;i--;)
	{
		for(j=19;j--;)
		{
			a[i][j]+=a[i+1][j]+a[i][j+1]-a[i+1][j+1];
		}
	}
	for(i=0;i<19;i++)
	{
		for(j=0;j<19;j++)
		{
			if(i>8&&j>8)s+=b[i][j]*(a[18-i][18-j]-1);
			else s+=b[i][j]*a[18-i][18-j];
		}
	}
	cout<<s/2;
}

Measured memory_bytes: 3740
n, m = gets.split.map(&:to_i)
h = Hash.new { [] }

m.times do
  a, b = gets.split.map(&:to_i)
  h[a] = h[a].push b
end

h[1].each do |island|
  if h[island].include? n
    puts 'POSSIBLE'
    exit
  end
end

puts 'IMPOSSIBLE'

Measured memory_bytes: 19324
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();
        int B = sc.nextInt();
        if("+".equals(S)){
            System.out.println(A+B);
        }else{
            System.out.println(A-B);
        }
    }
}

Measured memory_bytes: 9680
import bisect
MOD = 10**9+7
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
a = set(A)
b = set(B)
check = True
if len(a) != N or len(b) != M:
    check = False
ans = 1
for num in range(N*M,0,-1):
    tmp = 0
    if num in a and num in b: continue
    elif num in a:
        tmp = M - bisect.bisect_left(B,num)
    elif num in b:
        tmp = N - bisect.bisect_left(A,num)
    else:
        x = bisect.bisect_left(A,num)
        y = bisect.bisect_left(B,num)
        tmp = (N-x)*(M-y) - (M*N-num) 
    
    if tmp < 0 or check == False:
        check = False
        break
    ans *= tmp
    ans %= MOD

print(ans if check else 0)

Measured memory_bytes: 3316
import copy

class Dice(object):
	def __init__(self,List):
		self.face=List
		
	def n_spin(self,a_list):
		List=copy.copy(a_list)
		temp=List[0]
		List[0]=List[1]
		List[1]=List[5]
		List[5]=List[4]
		List[4]=temp
		return List
		
 	def s_spin(self,a_list):
 		List=copy.copy(a_list)
 		temp=List[0]
 		List[0]=List[4]
 		List[4]=List[5]
		List[5]=List[1]
		List[1]=temp
		return List
		
	def e_spin(self,a_list):
		List=copy.copy(a_list)
		temp=List[0]
		List[0]=List[3]
		List[3]=List[5]
		List[5]=List[2]
		List[2]=temp
		return List
		
 	def w_spin(self,a_list):
 		List = copy.copy(a_list)
 		temp=List[0]
 		List[0]=List[2]
 		List[2]=List[5]
		List[5]=List[3]
		List[3]=temp
		return List

n=input()
dice_List=[None]*n
emer=[None]*n
for a in range(n):
	dice_List[a]=Dice(map(int,raw_input().split()))
	emer[a]=copy.copy(dice_List[a].face)
judge=True
for b in range(1,n):
	face_storage=[]
	face_storage.append(emer[b])
	for c in range(24):
		face_storage.append((dice_List[b].n_spin(face_storage[c])))
		face_storage.append((dice_List[b].e_spin(face_storage[c])))
		face_storage.append((dice_List[b].w_spin(face_storage[c])))
		face_storage.append((dice_List[b].s_spin(face_storage[c])))
	for d in face_storage:
		if d==dice_List[0].face:
			judge=False
			break
if judge:
	print("Yes")
else :
	print("No")

Measured memory_bytes: 6580
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
P = [a if a > 0 else 0 for a in A]
M = [a if a < 0 else 0 for a in A]
W = [sum(P[:K])] * (N - K + 1)
B = [sum(M[:K])] * (N - K + 1)
for i in range(N - K):
  W[i + 1] = W[i] + P[i + K] - P[i]
  B[i + 1] = B[i] + M[i + K] - M[i]
print(sum(P) - min(min(W), -max(B)))

Measured memory_bytes: 14620
/**
 * B - Two Colors Card Game
 */

#include <iostream>
#include <unordered_map>

using namespace std;
using P = pair<string, int>;

int main() {

    unordered_map<string, int> map;
    int N, M;

    cin >> N;
    while (N--) {
        string s;
        cin >> s;
        if (map.find(s) == map.end()) {
            map[s] = 0;
        }
        map[s]++;
    }

    cin >> M;
    while (M--) {
        string s;
        cin >> s;
        if (map.find(s) == map.end()) {
            map[s] = 0;
        }
        map[s]--;
    }

    int ans = 0;

    for (P p : map) {
        ans = max(ans, p.second);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int longDistance = in.nextInt();
            int shortDistance = in.nextInt();
            int hour = in.nextInt();
            int minute = in.nextInt();

            double time = 60 * hour + minute;
            double kakudo = (time / (60 * 12)) * 360;
            double kakudoShort = ((double) minute / 60) * 360;
            double diff = Math.abs(kakudo - kakudoShort);

            double ans = Math.pow(longDistance, 2) +
                    Math.pow(shortDistance, 2) -
                    (2 * longDistance * shortDistance * Math.cos(Math.toRadians(diff)));

            out.append(String.valueOf(Math.sqrt(ans)));

        }

    }
}



Measured memory_bytes: 36052
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    string s;
    cin>>s;
    ll t = s.size()/2;
    ll su = 0;
    rep(i, t){
        if (s[i] != s[s.size()-1-i])
        {
            su++;
        }
        
    }pr(su);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w;

		while(true)
		{
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(x == 0 && y == 0)
			{
				break;
			} else {
				if(x > y)
				{
					w = x;
					x = y;
					y = w;
				}
			System.out.println(x + " " + y);
			}
		}
	}
}

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

int main() {
    string S,s1,s2;
    int n1,n2;

    cin >> S;

    s1 = S.substr(0,2);
    s2 = S.substr(2,2);

    n1 = atoi(s1.c_str());
    n2 = atoi(s2.c_str());

    if ((n1 > 0 && n1 < 13) && (n2 > 0 && n2 < 13)){
        cout << "AMBIGUOUS" << endl;
    }
    else if ((n1 > -1 && n1 < 100) && (n2 > 0 && n2 < 13)){
        cout << "YYMM" << endl;
    }
    else if ((n1 > 0 && n1 < 13) && (n2 > -1 && n2 < 100)){
        cout << "MMYY" << endl;
    }
    else {
        cout << "NA" << endl;
    }
}

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

int main() {
    int a[300] = {};
    char x, y, z;
    scanf("%c%c%c", &x, &y, &z);
    a[x]++; a[y]++; a[z]++;
    if(a['a'] == a['b'] && a['b'] == a['c']) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
class Dice:
    def __init__(self,surfaceNum):
        self.surface = surfaceNum
        
    def east(self):
        self.surface[0], self.surface[2], self.surface[5], self.surface[3] = self.surface[3], self.surface[0], self.surface[2], self.surface[5]
    def west(self):
        self.surface[0], self.surface[2], self.surface[5], self.surface[3] = self.surface[2], self.surface[5], self.surface[3], self.surface[0]
    def south(self):
        self.surface[0], self.surface[1], self.surface[5], self.surface[4] = self.surface[4], self.surface[0], self.surface[1], self.surface[5]
    def north(self):
        self.surface[0], self.surface[1], self.surface[5], self.surface[4] = self.surface[1], self.surface[5], self.surface[4], self.surface[0]
        
    def printTopSurface(self):
        print(self.surface[0])  

surfaceNum = [int(i) for i in input().split()]
rollCommand = list(input())
Dice = Dice(surfaceNum)

for i in range(len(rollCommand)):
    if rollCommand[i] == "E":
        Dice.east()
    if rollCommand[i] == "W":
        Dice.west()
    if rollCommand[i] == "S":
        Dice.south()
    if rollCommand[i] == "N":
        Dice.north()
    
Dice.printTopSurface()



Measured memory_bytes: 5612
import itertools

n = int(input())
lst = []
for _ in range(n):
  m = int(input())
  lst_s = []
  for _ in range(m):
    evi = list(map(int, input().split()))
    lst_s.append(evi)
  lst.append(lst_s)
#print(lst)

truth = [0, 1]
all_lists = list(itertools.product(truth, repeat=n))
#print(all_lists)
max_count = 0
for each in all_lists:
  flag = True
  count = 0
  #print(each)
  for i in range(n):
    trust = each[i]
    #print(trust)
    evis = lst[i]
    for evid in evis:
      #print(evid)
      person_ind = evid[0] - 1
      person_trust = evid[1]
      if trust == 1:
        if person_trust != each[person_ind]:
          flag = False
          break
    if not flag:
      break
    if trust == 1:
      count += 1
  if (count > max_count) and flag:
    max_count = count
print(max_count)

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

using namespace std;


int main(int argc, char** argv)
{
	string str;
	cin >> str;

	int S[3];
	::memset( S, 0, sizeof(int) * 3 );
	for (int i = 0; i < 3; ++i)
	{
		if (str[i] == 'a')
		{
			S[0]++;
		}
		else if(str[i] == 'b')
		{
			S[1]++;
		}
		else if (str[i] == 'c')
		{
			S[2]++;
		}
	}
	bool flg = false;
	for (int i = 0; i < 3; ++i)
	{
		if (S[i] == 0) flg = true;
	}
	
	if (!flg)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define ll long long
int gcd(int a,int b){
    int r = a % b;
    while(r > 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int  main(){
    int k;
    scanf("%d",&k);
    int ans = 0;
    for(int i = 1; i <= k; i++)
        for(int j = 1; j <= k; j++)
            for(int l = 1; l <= k; l++)
                ans += gcd(i, gcd(j, l));
    printf("%d\n",ans);
    return 0;
}

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

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

typedef long long ll;

int main(){
    int n;
    cin >> n;
    bool judge = false;
    if(n%10 == 7) judge = true;
    n /= 10;
    if(n%10 == 7) judge = true;
    n /= 10;
    if(n%10 == 7) judge = true;
    
    if(judge == true) cout << "Yes" << endl;
    if(judge == false) cout << "No" << endl;
    

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n); for(ll i = 0; i < ll(n); i++)
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}



int main(){
  int n;
  cin>>n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(),l.end());
  int ans=0;
  rep(i,n-2){
    for(int j=i+1; j<n-1; j++){
      /*for(int k=j+1; k<n; k++){
        if(max(l[i]-l[j],l[j]-l[i])<l[k]&&l[k]<l[i]+l[j]) ans++;
      }*/

      
      int lf=j+1,r=n-1,m;
      if(max(l[i]-l[j],l[j]-l[i])<l[r]&&l[r]<l[i]+l[j]){
        ans+=n-1-j;
      }
      else if(max(l[i]-l[j],l[j]-l[i])>=l[lf]||l[lf]>=l[i]+l[j]){
      }else{      
      while(r-lf>1){
        m=(lf+r)/2;
        if(max(l[i]-l[j],l[j]-l[i])<l[m]&&l[m]<l[i]+l[j]) lf=m;
        else r=m;
      }
      ans+=lf-j;
      }
    }
  }
  
  cout<< ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

  string s, t; cin >> s >> t;
  bool flag = false;
  rep(i, s.length()) {
    if(s==t) flag = true;
    char c = s[s.length()-1];
    for(int j = s.length()-1; j > 0; --j ) s[j] = s[j-1];
    s[0] = c;
  }
  cout << (flag ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int a[MAXN], n, M[MAXN][20];

void RMQ() {
    FOR(i,0,n+3) M[i][0] = a[i];
    for (int k = 1; (1<<k) <= n+3; k++)
        for (int i = 0; i + (1<<k) - 1 <= n+3; i++) M[i][k] = max(M[i][k-1], M[i+(1<<(k-1))][k-1]);
}

int get(int u, int v) {
    int k = log2(v - u + 1);
    return max(M[u][k], M[v-(1<<k)+1][k]);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);  
    cin >> n;
    FOR(i,2,n+1) cin >> a[i];
    a[0] = 10000000;
    a[1] = 1000000;
    a[n+2] = 1000000;
    a[n+3] = 10000000;
    RMQ();
    ll res = 0;
    FOR(i,2,n+1) {
        int dau = 0, cuoi = i-1, mid;
        while (dau <= cuoi) {
            mid = (dau + cuoi) / 2;
            if (get(mid, i) > a[i]) dau = mid+1;
            else cuoi = mid-1;
        }
        int fiLeft = cuoi;
        dau = 0, cuoi = fiLeft - 1;
        while (dau <= cuoi) {
            // cout << dau << ' ' << cuoi << endl;
            mid = (dau + cuoi) / 2;
            if (get(mid, fiLeft-1) > a[i]) dau = mid+1;
            else cuoi = mid-1;
        }
        int seLeft = cuoi;

        dau = i+1, cuoi = n+3, mid;
        while (dau <= cuoi) {
            mid = (dau + cuoi) / 2;
            if (get(i, mid) > a[i]) cuoi = mid-1;
            else dau = mid+1;
        }
        int fiRight = dau;
        dau = fiRight+1, cuoi = n+3;
        while (dau <= cuoi) {
            mid = (dau + cuoi) / 2;
            if (get(fiRight+1, mid) > a[i]) cuoi = mid-1;
            else dau = mid+1;
        }
        int seRight = dau;

        // cout << seLeft << ' ' << fiLeft << ' ' << fiRight << ' ' << seRight << endl;
        if (fiRight < n+2) {
            res += (ll) (i - fiLeft) * (seRight - fiRight) * a[i];
        }
        if (fiLeft > 1) {
            res += (ll) (fiRight - i) * (fiLeft - seLeft) * a[i];
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <vector>
using namespace std;
#define limn 3005
vector<int>kolejka;
string s1,s2;
int tab[limn][limn];
int d1,d2;
void licz()
{
    for(int i=1; i<=s1.size(); i++)
    {
        for(int j=1; j<=s2.size(); j++)
        {
            if(s1[i-1]==s2[j-1])
                tab[i][j]=tab[i-1][j-1]+1;
            else
                tab[i][j]=max(tab[i-1][j],tab[i][j-1]);
        }
    }
}
void droga()
{
    int endd=tab[s1.size()][s2.size()];
    int x=s1.size(),y=s2.size();
    for(int i=0;i!=endd;i)
    {
        if(s1[x-1]==s2[y-1])
        {
            kolejka.push_back(s1[x-1]);
            i++;
            x--;
            y--;
        }
        else
        {
            if(tab[x-1][y]>tab[x][y-1])
            {
                x--;
            }
            else
                y--;
        }

    }
    //cout<<kolejka.size();
    for(int i=kolejka.size()-1;i>=0;i--)
        cout<<char(kolejka[i]);
}
void wczytaj()
{
    cin>>s1>>s2;
    licz();
    droga();
}
int main()
{
    ios_base::sync_with_stdio();
    wczytaj();

    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
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 (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int main(){
    fastcin();

    LL a, b, c;
    cin >> a >> b >> c;
    LL d = c-a-b;
    if(d < 0){
        cout << "No" << endl;
        return 0;
    }
    d *= d;
    cout << (4*a*b < d ? "Yes":"No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("C:/Users/Aman/Desktop/kachda/input.txt", "r", stdin); freopen("C:/Users/Aman/Desktop/kachda/output.txt", "w", stdout);

using namespace std;

signed main()
{
	//FILEIO
 	FAST
	bool b[4] = {0};
	fr(i,1,5)
	{
		int x;
		cin>>x;
		if( x == 1) b[0] = 1;
		if(x == 9) b[1] = 1;
		if(x == 4) b[2]  = 1;
		if(x == 7) b[3] = 1; 
	}

	fr(i,0,4)
	{
		if(b[i] == 0) return cout<<"NO\n", 0;
	}
	cout<<"YES\n";

}

Measured memory_bytes: 256
from collections import deque

def get_lunlun(i):
    ret = [i]
    if i  > 0:
        ret.append(i-1)
    if i < 9:
        ret.append(i+1)
    return sorted(ret)

def main():
    n = int(input())
    cand = deque()
    adj = {i: get_lunlun(i) for i in range(0,10)}
    for i in range(1, 10):
        cand.append(i)
    for _ in range(n):
        pos = cand.popleft()
        for cnd in adj[pos%10]:
            cand.append(pos*10+cnd)
    print(pos)

if __name__ == '__main__':
    main()



Measured memory_bytes: 12396
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
    int a;
    int p[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> a;
    cout << p[a - 1];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
signed main(){
  int n,a[1000];
  int ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]&&a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]){
          ans++;
        }
      }
    }
  }
  cout<<ans<<"\n";
}

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

int main(){
  long long a,b,k;
  cin>>a>>b>>k;
  if(a>=k) a-=k;
  else if(a<k&&a+b>=k) {
    b=b-(k-a);
    a=0;
  }
  else{
    a=0;
    b=0;
  }
  cout<<a<<" "<<b<<endl;
}
  


Measured memory_bytes: 256
// D - Water Bottle
#include <bits/stdc++.h>
using namespace std;
using dbl = double;

int main(){
	dbl a,b,x; cin>>a>>b>>x;
	dbl s = x/a;
	dbl h = b, w = a;
	if(s < a*b/2) w = s/b*2;
	else h = (b-s/a)*2;
	printf("%.10f\n", atan2(h, w)*180/M_PI);
}

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

int main()
{
	for(int i = 1; i <= 9; i++)
	{
		for(int j = 1; j <= 9; j++)
		{
			printf("%dx%d=%d\n", i, j, i * j);
		}
	}
    return 0;
}

Measured memory_bytes: 1096
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int64_t n;
  int64_t cnt=0;
  cin >> n;
  for(int64_t i=1;i < n+1;i++)
  {
    if(!(i%3==0) && !(i%5==0))
    {
      cnt+=i;
    }
  }
  cout << cnt;
  return 0;
}

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

int main() {

	int n;
	int bunkatu;
	cin >> n;

	vector<int> d(n);
	for (int i = 0; i < n; i++) {
		cin >> d.at(i);
	}
	std::sort(d.begin(), d.end());


	bunkatu = n / 2;

	if (d.at(bunkatu) != d.at(bunkatu - 1)) {
		cout << d.at(bunkatu) - d.at(bunkatu - 1) << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}
template <class T1, class T2> ostream& operator<<(ostream &O, const pair<T1,T2>& p) {return O << '(' << p.first << ' ' << p.second << ')';}





void _main() {
        int n, k; cin >> n >> k;
        vector<int> a(n); cin >> a;
        int m = *min_element(all(a));
        int ans = n;
        for (int i = 0; i < n; i++) {
                if (a[i] == m) {
                        int cnt = 0;
                        for (auto j: {n - i}) {
                                cnt += (n - k + k - 2) / (k - 1);
                        }
                        ans = min(ans, cnt + 1);
                }
        }

        cout << ans;
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3692
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define MX 505

using namespace std;

int arr[MX][MX];
int opr[MX*MX][4], num;

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
			scanf("%d", &arr[i][j]);
	for(int i=1; i<=n; i++)
		for(int j=1; j<m; j++)
			if(arr[i][j] & 1)
			{
				arr[i][j]--, arr[i][j+1]++;
				num++;
				opr[num][0] = i;
				opr[num][1] = j;
				opr[num][2] = i;
				opr[num][3] = j+1;
			}
	for(int i=1; i<n; i++)
		if(arr[i][m] & 1)
		{
			arr[i][m]--, arr[i+1][m]++;
			num++;
			opr[num][0] = i;
			opr[num][1] = m;
			opr[num][2] = i+1;
			opr[num][3] = m;
		}
	printf("%d\n", num);
	for(int i=1; i<=num; i++)
		printf("%d %d %d %d\n", opr[i][0], opr[i][1], opr[i][2], opr[i][3]);
	return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int d,g;
    cin >> d >> g;

    vector<int> p(d);
    vector<int> c(d);

    for(int i=0; i<d; i++){
        cin >> p[i] >> c[i];
    }

    int ques = 1 << 29;

    for(int bit=0; bit < (1 << d); bit++){
        int sum=0;
        int num=0;
        bool flg=false;
        for(int i=0; i<d; i++){
            if(bit & (1 << i)){
                sum+=c[i]+p[i]*100*(i+1);
                num+=p[i];                
            }
        }

        if(sum>=g) ques=min(ques,num);
        else{
            for(int i=d-1; i>=0; i--){
                if(!(bit & (1 << i))){
                    for(int j=0; j<p[i]; j++){
                        sum+=100*(i+1);
                        num++;
                        if(sum>=g){
                            flg=true;
                            break;
                        };
                    }
                }
                if(flg) break;
            }
            ques=min(ques,num);
        }
    }

    cout << ques << endl;

    return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    int N, M, A[101];
    cin >> N >> M;
    REP(i, N) cin >> A[i];
    int sum = accumulate(A, A + N, 0);
    int cnt = 0;
    REP(i, N) if(A[i] * 4 * M >= sum) cnt++;
    if(cnt >= M) PRINT("Yes");
    else PRINT("No");
    return 0;
}

Measured memory_bytes: 256
// SeeAlso: https://atcoder.jp/contests/nikkei2019-2-qual/tasks/nikkei2019_2_qual_a

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

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

    print((N-1)/2);
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())

an = list(map(int,input().split()))

boolian = True

for i in range(N):
    if an[i] % 2 == 0:
        if an[i] % 3 ==0 or an[i] % 5 ==0:
            boolian = True
        else:
            boolian = False
            break
if boolian == False:
    print('DENIED')
    
if boolian == True:
    print('APPROVED')

Measured memory_bytes: 9188