akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int n; cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    int A=0,B=0;
    for(int i=0;i<n;i++){
        if(i%2) A+=a[i];
        else B+=a[i];
    }
    cout<<abs(A-B)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[10000],i=0,k=0,j,l;
	while(k==0){
		scanf("%d %d",&a[i],&a[i+1]);
		if(a[i]==0 && a[i+1]==0){
			k=1;
		}else{
			i=i+2;
		}
	}
	l=i/2;
	int x,y;
	for(j=1;j<=l;j++){
		for(x=1;x<=a[2*j-2];x++){
			for(y=1;y<=a[2*j-1];y++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, s.size()){
    if(s[i] != t[i]){
      ans ++;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

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

int main(){
    string str;
    cin >> str;
    int cnt = 0;
    rep(i,str.length()){
        if(str[i] == '1')cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
like = list(map(str, set(range(10)) - set(map(int, input().split()))))

while True:
  count = 0
  for c in str(n):
    if c in like:
      count += 1
      
  if count == len(str(n)):
    print(n)
    break
  
  n += 1

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long Int;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,ans;
    cin >> N;
    ans = ((N-1)/111+1) * 111;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*
*/

//#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 300031;

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

		string st;
		cin>>st;
		for (int i=0;i+2<st.size();i++){
			if (st[i]==st[i+1]&&st[i+1]==st[i+2]){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
		cout<<"No"<<endl;

	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;


int main()
{
   int n,i,j,k,h,w;cin>>h>>w;
   char m[h+1][w+1];
   bool vis[h+1][w+1];
   for(i=0;i<h;i++)
   {
       for(j=0;j<w;j++) vis[i][j]=true;
   }
   for(i=0;i<h;i++)
   {
       for(j=0;j<w;j++) cin>>m[i][j];
   }

   for(i=0;i<h;i++)
   {
       int c=0;
       for(j=0;j<w;j++)
       {
           if(m[i][j]=='.') c++;
       }
       if(c==w)
       {
           for(j=0;j<w;j++) vis[i][j]=false;
       }
   }
   for(j=0;j<w;j++)
   {
       int c=0;
       for(i=0;i<h;i++)
       {
           if(m[i][j]=='.') c++;
       }
       if(c==h)
       {
           for(i=0;i<h;i++) vis[i][j]=false;
       }
   }
   for(i=0;i<h;i++)
   {
       bool f=false;
       for(j=0;j<w;j++)
       {
           if(vis[i][j]) {cout<<m[i][j];f=true;}
       }
       if(f) cout<<endl;
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define fi first 
#define se second
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
// ミント
const int mod = 1e9+7 ;
 // 998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n,int k){
    return fact[n]*ifact[n-k] ;
  }
}   c(200005);
 
mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

mint komb(ll n,ll m){
  mint x=1 ;mint y=1 ;
  rep(i,m){
    x*= n-i ;
    y*= i+1 ;
  }
  return x/y ;
}

 
 map<ll,ll> factor(ll n){  //素因数とオーダーをマップで管理
  map <ll,ll> ord ;  
  for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
   if(n!=1) ord[n]++;
   return ord ;
 }

int main(){
 ll n ; cin>>n ;
 string s ,t ; cin>>s>> t ;
 mint ans =1 ; 
 rep(i,n){
  if(i==0){
    if(s[i]==t[i]) ans *= 3 ;
    else ans *= 6 ;
  }
  else{
    if(s[i]==t[i]){
      if(s[i-1]==t[i-1])
      ans *= 2 ;
    }
    else{
      if(s[i-1]!=s[i]){
        if(s[i-1]==t[i-1]) ans*= 2;
        else ans *= 3 ;
      }
    }
  }
 }
 cout<<ans<<endl ;
    return 0;
  }
   



Measured memory_bytes: 6216
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int d[1001],val[1001];
int dp[1001][(1<<12)+2],n,m;
int fun(int idx,int mask)
{
    if(mask==(1<<n)-1) return 0;
    if(idx==m) return 1e9;
    int &ret=dp[idx][mask];
    if(~ret) return ret;
    return ret=min(val[idx]+fun(idx+1,mask|d[idx]),fun(idx+1,mask));
}
signed main()
{

    memset(dp,-1,sizeof dp);
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int sz,x;
        cin>>val[i]>>sz;
        while(sz--)
        {
            cin>>x;
            x--;
            d[i]|=(1<<x);
        }
    }
    int ans=fun(0,0);
    cout<<(ans>=1e9?-1:ans)<<endl;
	return 0;
}


Measured memory_bytes: 19696
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 10000001

ll p[N];

void seive() {
    p[1] = 0;
    ifr(i, 2, N) {
        for(ll j=i;j<N;j+=i)
            p[j]++;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
    #endif
    // int T;cin>>T;while(T--) 
    {
        int n;
        cin>>n;
        seive();
        ll ans = 0;
        ifr(i, 1, n+1) {
            // cout<<i<<" "<<p[i]<<endl;
            ans += 1ll*i*(p[i]+1);
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i =0; i < N; i++){
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  int mid = N/2-1;
  int ans = d.at(mid+1) - d.at(mid);
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define M (ll)1000000007
#define MM (ll)1e8
#define INF (ll)1e18
#define arep(i, x, n) for (long long i = x; i < n; i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001

int main() {
    ll n;
    cin >> n;
    ll t[n];
    ll x[n];
    ll y[n];

    rep(i, n) { cin >> t[i] >> x[i] >> y[i]; }

    ll prevX = 0;
    ll prevY = 0;
    ll prevT = 0;
    bool canGO = true;
    rep(i, n) {
        ll dist = abs(x[i] - prevX) + abs(y[i] - prevY);
        if (dist <= t[i] - prevT && (t[i] - prevT - dist) % 2 == 0) {
            prevX = x[i];
            prevY = y[i];
            prevT = t[i]; 
        } else {
            canGO = false;
            break;
        }
    }

    if (canGO)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 5904
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

bool check(string S, string T) {
    while (!S.empty && !T.empty) {
        if (S.length > T.length) {
            swap(S, T);
        }
        if (T.startsWith(S)) {
            T = T[S.length..$];
        } else {
            return false;
        }
    }
    return true;
}

void main() {
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;
    auto T = readln.chomp;

    bool loop = check(S, T);

    for (int i = 0, j = 0; !loop; i = (i + 1) % S.length.to!int, j = (j + 1) % T.length.to!int) {
        if (S[i] < T[j]) {
            break;
        } else if (S[i] > T[j]) {
            swap(S, T);
            break;
        }
    }

    int X = (N - 1) / S.length.to!int + 1;
    X = X * S.length.to!int;
    while (X > N || (N - X) % T.length != 0) {
        X -= S.length.to!int;
    }

    string ans = "";
    while (ans.length < X) ans ~= S;
    while (ans.length < N) ans ~= T;

    ans.writeln;
}


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

const int MAXN = int( 2e5 );
const int MAXQ = int( 2e5 );

int N, Q, A, B;
int X[ MAXQ + 1 ];

const long long INF64 = 0x3f3f3f3f3f3f3f3fLL;

#define minus __myminus
#define plus __myplus

struct itvt {
  long long minv[ MAXN << 2 ];
  long long tag[ MAXN << 2 ];
  void init() {
    memset( minv, INF64, sizeof( minv ) );
  }
  void pull( int t ) {
    minv[ t ] = min( minv[ t << 1 ], minv[ t << 1 | 1 ] );
  }
  void push( int t ) {
    minv[ t << 1 ] += tag[ t ];
    tag[ t << 1 ] += tag[ t ];
    minv[ t << 1 | 1 ] += tag[ t ];
    tag[ t << 1 | 1 ] += tag[ t ];
    tag[ t ] = 0;
  }
  void update( int t, int lb, int rb, int k, long long v ) {
    if( lb + 1 == rb ) {
      minv[ t ] = min( minv[ t ], 1LL * v );
      return;
    }
    int mid = lb + rb >> 1;
    push( t );
    if( k < mid ) update( t << 1, lb, mid, k, v );
    else update( t << 1 | 1, mid, rb, k, v );
    pull( t );
  }
  long long query( int t, int lb, int rb, int ql, int qr ) {
    if( qr <= lb or rb <= ql ) return INF64;
    if( ql <= lb and rb <= qr ) return minv[ t ];
    int mid = lb + rb >> 1;
    push( t );
    long long res = min( query( t << 1, lb, mid, ql, qr ), query( t << 1 | 1, mid, rb, ql, qr ) );
    pull( t );
    return res;
  }
} minus, plus;

signed main() {
  ios::sync_with_stdio( 0 );
  cin >> N >> Q >> A >> B;
  --A, --B;
  for( int i = 1; i <= Q; ++i ) {
    cin >> X[ i ];
    --X[ i ];
  }
  X[ 0 ] = A;
  minus.init();
  plus.init();
  minus.update( 1, 0, N, B, -B );
  plus.update( 1, 0, N, B, B );
  for( int i = 1; i <= Q; ++i ) {
    int x = X[ i ];
    long long to_x = min( x + minus.query( 1, 0, N, 0, x ), plus.query( 1, 0, N, x, N ) - x );
    minus.minv[ 1 ] += abs( X[ i ] - X[ i - 1 ] );
    minus.tag[ 1 ] += abs( X[ i ] - X[ i - 1 ] );
    plus.minv[ 1 ] += abs( X[ i ] - X[ i - 1 ] );
    plus.tag[ 1 ] += abs( X[ i ] - X[ i - 1 ] );
    minus.update( 1, 0, N, X[ i - 1 ], to_x - X[ i - 1 ] );
    plus.update( 1, 0, N, X[ i - 1 ], to_x + X[ i - 1 ] );
  }
  long long ans = INF64;
  for( int i = 0; i < N; ++i ) {
    ans = min( ans, minus.query( 1, 0, N, i, i + 1 ) + i );
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(void){
	char c1, c2, c3;
	char t1, t2, t3;
	for(int i = 0;i < 3;++i){
		cin >> c1 >> c2 >> c3;
		if(i == 0){
			t1 = c1;
		}else if(i == 1){
			t2 = c2;
		}else{
			t3 = c3;
		}
	}

	printf("%c%c%c\n", t1, t2, t3);

	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = [] #happiness
for i in range(n):
  a_input, b_input, c_input = map(int, input().split())
  h.append([a_input, b_input, c_input])

dp = [[0 for _ in range(3)] for _ in range(n+1)]


for i in range(1, n+1):
  for j in range(3):
    for k in range(3):
      if j != k and dp[i][j] < dp[i-1][k] + h[i-1][j]:
        dp[i][j] = dp[i-1][k] + h[i-1][j]

ans = 0
for j in range(3):
  if ans < dp[n][j]:
    ans = dp[n][j]

print(ans)

Measured memory_bytes: 74584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int cap = N;
		int fx = 0;
		for(int i = (int)Math.log10(N);i >= 0;--i) {
			fx += cap / Math.pow(10, i);
			cap = cap % (int)Math.pow(10, i);
		}
		
		if(N % fx == 0)
			System.out.println("Yes");
		else
			System.out.println("No");
		sc.close();
	}
}

Measured memory_bytes: 21844
import java.util.*;

public class Main{

	public static void main(String[] args) {
		int count = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0 ;i < n;i++) {
			a[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int[] b = new int[m];
		for(int j = 0 ;j < m;j++) {
			b[j] = sc.nextInt();
		}
		sc.close();
		for(int j = 0 ;j < m;j++) {
			if(binarySearch(a,b[j]) == 1) {
				count++;
			}
		}
		System.out.println(count);
	}

	public static int binarySearch(int[] arr, int x) {
		int left = 0;
		int right = arr.length-1;
		int mid ;
		while(left <= right) {
			mid = (left+right)/2;
			if(arr[mid] == x) {
				return 1;
			}else if(arr[mid] > x) {
				right = mid-1;
			}else {
				left = mid+1;
			}
		}
		return 0;
	}

}


Measured memory_bytes: 67864
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m; cin >> n >> m;
    int answer = 0;
    set<int> ac;
    vector<int> v(n + 1);
    for(int i = 0; i < m; i++)
    {
        int w; string s; cin >> w >> s;
        if(s == "WA")
        {
            v[w]++;
        }
        else
        {
            answer += max(0, v[w]);
            v[w] = INT_MIN;
            ac.insert(w);
        }
    }
    cout << ac.size() << ' ' << answer;
    return 0;
}

Measured memory_bytes: 5376
#include<cstdio>
#include<cstring>
using namespace std;

char s[10];
int val,fx;

int main(){
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len;i++){
		val*=10;
		val+=s[i]-'0';
		fx+=s[i]-'0';
	}
	if(val%fx==0)
		puts("Yes");
	else
		puts("No");
	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL a(n);
	cin >> a;
	SORT(a);
	VL rui(n+1);
	rui[0] = 0;
	for (int i = 0; i < n; i++) {
		rui[i+1] = rui[i] + a[i];
	}
	int x = 0;
	for (int i = 0; i < n; i++) {
		if (rui[i]*2 < a[i]) {
			x = i;
		}
	}
	cout << n - x << endl;
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <numeric>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <typename T>
vector<T> apply(vector<T> const & a, vector<int> const & swp) {
    int n = swp.size();
    vector<T> b(n);
    repeat (i,n) b[i] = a[swp[i]];
    return b;
}
int main() {
    int n; cin >> n;
    vector<ll> x(n); repeat (i,n) cin >> x[i];
    int m; ll k; cin >> m >> k;
    vector<int> a(m); repeat (i,m) { cin >> a[i]; -- a[i]; }
    vector<ll> dx(n-1); repeat (i,n-1) dx[i] = x[i+1] - x[i];
    vector<int> swp(n-1); whole(iota, swp, 0);
    repeat (j,m) swap(swp[a[j]-1], swp[a[j]]);
    for (ll i = 1; i <= k; i <<= 1) {
        if (k & i) dx = apply(dx, swp);
        swp = apply(swp, swp);
    }
    vector<ll> y(n);
    y[0] = x[0]; repeat (i,n-1) y[i+1] = y[i] + dx[i];
    repeat (i,n) cout << y[i] << endl;
    return 0;
}

Measured memory_bytes: 5200
#include<bits/stdc++.h>
int main()
{
    int a,b,t,t1,t2,t3;
    scanf("%d%d",&a,&b);
    t1 = a+b;
    t2 = a-b;
    t3 = a*b;
    t= t1 > t2 ? t1:t2;
    t= t > t3 ? t:t3;
    printf("%d",t);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define high 100000000000
int n,k;

void func(int x,long long int *a,long long int *b)
{
	int i;
	if(x==n-1) return;
	for(i=0;i<k;i++)
	{
		// if(b[x+1]>b[x]+abs(a[x+1]-a[x])) b[x+1]=b[x]+abs(a[x+1]-a[x]);
		if(x<=n-i-1)if(b[x+i+1]>b[x]+abs(a[x+i+1]-a[x])) b[x+i+1]=b[x]+abs(a[x+i+1]-a[x]);
	}
	return func(x+1,a,b);
}

int main()
{
	
	cin>>n>>k;
	long long int a[n],i,b[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=high;
	}
	b[0]=0;
	func(0,a,b);
	cout<<b[n-1]<<endl;
	return 0;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
signed main(){
  char a;
  cin>>a;
  if(a=='A')
    cout<<"T"<<endl;
  if(a=='T')
    cout<<"A"<<endl;
  if(a=='G')
    cout<<"C"<<endl;
  if(a=='C')
    cout<<"G"<<endl;
  return(0);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <array>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#define MOD 1000000007
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

LL n, s;
LL ans;

bool f(LL b)
{
	LL sum = 0, n_copy = n;
	while (n_copy)
	{
		sum += n_copy % b;
		n_copy /= b;
	}
	return (sum == s ? true : false);
}

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

	if (n == s)
	{
		out << n + 1 << std::endl;
		return 0;
	}
	for (LL i = 2; i <= std::sqrt(n); ++i)
	{
		if (f(i) == true)
		{
			out << i << std::endl;
			return 0;
		}
	}
	ans = n + 1;
	for (LL i = 1; i <= std::sqrt(n); ++i)
	{
		LL res = (n - s) / i + 1;
		if (res > 1 && f(res) == true)
		{
			ans = std::min(ans, res);
		}
	}

	if (ans == n + 1)
	{
		out << -1 << std::endl;
	}
	else
	{
		out << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        boolean bool = a % 2 == 0
                || b % 2 == 0;
        System.out.println(bool ? "No" : "Yes");
    }
}


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

using namespace std;

////////////////////
class Edge{
public:
    int from, to, cost;
};

vector < vector < Edge > > edge; // 隣接リスト
vector <bool> visited; // 訪問状況
vector <long> vertex;

void dfs(long now, long point){
    int l=edge[now].size();
    for(int i=0; i<l; i++){
        if(!visited[edge[now][i].to]){
            visited[edge[now][i].to]=true;
            vertex[edge[now][i].to] += point;
            //cout<<now<<" "<<edge[now][i].to<<" "<<vertex[edge[now][i].to]<<endl;
            dfs(edge[now][i].to, vertex[edge[now][i].to]);
        }
    }
}

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

int main(){
    long n; // 点数
    long m; // 辺数
    long from, to;

    long q;

    // 入力
    cin>>n>>q;
    edge.resize(n);
    m = n-1;
    for(int i=0; i<m; i++){
        cin>>from>>to;
        //入力される値の範囲, 添字と同じ？
        edge[from-1].push_back((Edge){from-1, to-1, 0});
    }

    vertex.resize(n, 0);
    long p, x;
    for(int i=0; i<q; i++){
        cin>>p>>x;
        vertex[p-1] += x;
    }


    // 初期設定
    visited.resize(n);
    for(int i=0; i<n; i++){
        visited[i]=false;
    }

    // 探索
    int start=0; // 探索開始ノード
    long point = vertex[0];
    visited[start]=true;
    dfs(start, point);



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

    return 0;
}


Measured memory_bytes: 24320
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    vector<string> s(3);
    for (int i = 0; i < 3; i++) cin >> s[i];

    for (int i = 0; i < 3; i++) cout << (char)(s[i].front() - 0x20);
    cout << endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] strArr = br.readLine().split(" ");
        int a = Integer.parseInt(strArr[0]);
        int b = Integer.parseInt(strArr[1]);
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}

Measured memory_bytes: 24208
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

int main() {

    int A, B, C;
    cin >> A >> B >> C;

    if (A > B) {
        int tmp = B;
        B = A;
        A = tmp;
    }


    if (A < C && C < B)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}



Measured memory_bytes: 256
/*
	Name: zhao yi (HangZhou JianLan Middle School, China) 
	Copyright: hkxadpall
	Author: hkxadpall
	Date: 2018-10-18
	Description: the program that can solve Luogu-P1981      
*/
#include <queue>
#include <vector>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
using std::max;
using std::min;
using std::cerr;
using std::endl;
using std::sort;
using std::queue;
using std::vector;
using std::priority_queue; 

struct fast_IO {
#define fast_IO_all_DEBUG 0
#define fast_IO_read_DEBUG 0
#define fast_IO_write_DEBUG 0
	
	bool __read_sign_LowThan0; 
	char __read_buf_ch; 
	
	template <typename type> 
	void read(type &res)
	{
		__read_sign_LowThan0 = 0;
		__read_buf_ch = getchar();
		while (__read_buf_ch > '9' || __read_buf_ch < '0') {
			if (__read_buf_ch == '-') {
				__read_sign_LowThan0 = 1;
				__read_buf_ch = getchar();
				break;
			}
			__read_buf_ch = getchar();
		}
		res = (__read_buf_ch & 15); 
		__read_buf_ch = getchar();
		while (__read_buf_ch <= '9' && __read_buf_ch >= '0') {
			res = (res << 3) + (res << 1) + (__read_buf_ch & 15); 
			__read_buf_ch = getchar();
		}
		if (__read_sign_LowThan0) {
			res = ((~res) + 1);
		} 
#if fast_IO_all_DEBUG || fast_IO_read_DEBUG
		printf("[TEST $ read %d $ ]", res);
#endif
	}
} io;

#define read io.read
#define write io.write	

#define passing() fprintf(stderr, "passing line [%d] in function %s.\n", __LINE__, __FUNCTION__)
#define debug(x) cerr << "[debug] " << #x << " = " << x << endl 

#define INF_int(bit) ((1 << (bit - 2)) - 1)

#define Max_N (1000000 + 3)      
#define Max_X (9 + 3)        
#define P 10007     
  
int n;
//int a[Max_N] = {0}; 
char ch[5] = {0};

int main()
{
//	read(n);
	scanf("%s", ch);
	if (ch[2]  == 0) {
		printf("%s", ch);
	} else {
		printf("%c%c%c", ch[2], ch[1], ch[0]);
	}
	return 0;
}

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

int linearSearch(int *, int, int);

main(){
  int n,q,i,findN=0;
  int *sAry, *tAry;

  scanf("%d", &n);
  sAry = (int *)malloc((n+1)*sizeof(int)); //番兵用に+1
  for(i=0; i<n; i++) scanf("%d", sAry+i);
  scanf("%d", &q);
  tAry = (int *)malloc(q*sizeof(int));
  for(i=0; i<q; i++) scanf("%d", tAry+i);

  for(i=0; i<q; i++){
    //printf("%d: %d\n", tAry[i], linearSearch(sAry, n, tAry[i]));
    findN+=linearSearch(sAry, n, tAry[i]);
  }

  printf("%d\n", findN);

  return 0;
}

int linearSearch(int *ary, int n, int a){
  int i=0;
  ary[n]=a;
  while(ary[i]!=a) i++;
  if(i==n) return 0;
  return 1;
}

Measured memory_bytes: 636
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int N;
	cin >> N;
	VI a(N);
	REP(i, N) cin >> a[i];
	sort(a.begin(), a.end(), greater<int>());
	int A = 0, B = 0;
	REP(i,N){
		if (i % 2 == 0) A += a[i];
		if (i % 2 == 1) B += a[i];	
	}
	cout << A - B << endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include <math.h>
#include<iostream>
using namespace std;
typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         ld;

#define sf                  scanf
#define pf                  printf
#define srev                reverse(s.begin(),s.end())
#define sortstr             sort(s.begin(), s.end());
#define gtl(x)              getline(cin, (x))
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define PI                  acos(-1)
#define Precision(a) cout << fixed << setprecision(a)
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template <typename T> T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());

int main()
{
    FasterIO
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5])
       cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

namespace _20170409_AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] iArr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int w = iArr[0];
            int h = iArr[1];
            int x = iArr[2];
            int y = iArr[3];
            int r = iArr[4];

            if (w >= x + r && 0 <= x - r && h >= y + r && 0 <= y - r)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9408
import java.util.*;

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

        int N = 101010;
        int [] is_prime = new int [N+1];

        for (int i = 2; i <= N; i++) is_prime[i] = 1;

        for (int i = 2; i <= N; i++) {
            if (is_prime[i] == 1) {
                for (int k = 2; i*k <= N; k++ ) is_prime[i*k] = 0;
            }
        }

        int [] a = new int [N];
        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) continue; 
            if (is_prime[i] == 1 && is_prime[(i+1)/2] == 1 ) a[i] = 1;
        }

        int [] s = new int [N+1];
        for (int i = 0; i < N; i++) s[i+1] = s[i] + a[i];

        int Q = sc.nextInt();
        for (int q = 0; q < Q; q++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(s[r+1] - s[l]);
        }
    }
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p.at(i);
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < k; i++) {
    ans += p.at(i);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  vector<vector<int> > e(n),r(n);
  for(int i=0;i<m;i++){
    int a,b;
    scanf("%d%d",&a,&b);
    a--;
    b--;
    e[a].push_back(b);
    r[b].push_back(a);
  }
  long long ans=0;
  static int V[100000];
  for(int i=0;i<n;i++){
    V[i]=-1;
  }
  for(int i=0;i<n;i++){
    if(V[i]!=-1){
      continue;
    }
    queue<int> Q;
    Q.push(i);
    bool F=0;
    int c=0,C[3]={0};
    V[i]=0;
    C[0]++;
    while(!Q.empty()){
      int j=Q.front();
      Q.pop();
      int v=V[j];
      for(int x=0;x<e[j].size();x++){
	int k=e[j][x];
	c++;
	if(V[k]==-1){
	  V[k]=(v+1)%3;
	  C[V[k]]++;
	  Q.push(k);
	}
	else if(V[k]!=(v+1)%3){
	  F=1;
	}
      }
      for(int x=0;x<r[j].size();x++){
	int k=r[j][x];
	if(V[k]==-1){
	  V[k]=(v+2)%3;
	  C[V[k]]++;
	  Q.push(k);
	}
	else if(V[k]!=(v+2)%3){
	  F=1;
	}
      }
    }
    if(F){
      int A=C[0]+C[1]+C[2];
      ans+=(long long)A*A;
    }
    else if(C[1]==0||C[2]==0){
      ans+=c;
    }
    else{
      ans+=(long long)C[0]*C[1]+(long long)C[1]*C[2]+(long long)C[2]*C[0];
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 11648
#include<stdio.h>
#include<vector>

using namespace std;

vector<int> con[100001];
long long res;
int mod=1000000007;
int k;
long long mul[100001];
long long inv[100001];

int c(int x,int y) {
	if (y==0) return 1;
	if (x<y) return 0;
	return (mul[x]*inv[x-y])%mod;
}

void dfs(int x,int y) {
	if (y==0) res=(res*c(k-1,con[x].size()))%mod;
	else res=(res*c(k-2,con[x].size()-1))%mod;
	int i;
	for (i=0;i<con[x].size();i++)
		if (con[x][i]!=y) dfs(con[x][i],x);
}

long long p(long long x, int y) {
	long long ret=1;
	while (y>0) {
		if (y%2==1) ret=(ret*x)%mod;
		y=y/2;
		x=(x*x)%mod;
	}
	return ret;
}

int main()
{
	int n;
	int i;
	scanf("%d%d",&n,&k);
	mul[0]=1;
	inv[0]=1;
	mul[1]=1;
	inv[1]=1;
	for (i=2;i<=k;i++) {
		mul[i]=(mul[i-1]*i)%mod;
		inv[i]=p(mul[i],mod-2);
	}
	
	for (i=1;i<n;i++) {
		int a,b;
		scanf("%d%d",&a,&b);
		con[a].push_back(b);
		con[b].push_back(a);
	}
	if (k==1) {
		if (n==1) printf("1\n");
		else printf("0\n");
		return 0;
	}
	if (k==2) {
		if (n<=2) printf("2\n");
		else printf("0\n");
		return 0;
	}
	res=k;
	dfs(1,0);
	printf("%lld\n",res);
	return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int a[3], res, k, b[] = {1, 0, -1};

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

	forn (i, 3) cin >> a[i];
	cin >> k;
	
	forn (i, 3) {
		int d = min(k, a[i]);
		res += d * b[i];
		k -= d;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>

void merge(int A[],int left,int mid,int right,int *cnt){
  int i,j,k,n1,n2;
  int L[500001],R[500001];

  n1=mid-left;
  n2=right-mid;

  for(i=0;i<n1;i++)
    L[i]=A[left+i];
  for(i=0;i<n2;i++)
    R[i]=A[mid+i];

  L[n1]=1000000001;
  R[n2]=1000000001;

  i=0;
  j=0;

  for(k=left;k<right;k++){
    if(L[i]<=R[j]){(*cnt)++;
      A[k]=L[i];
      i++;
    }
    else{(*cnt)++;
      A[k]=R[j];
      j++;
    }
  }


}

void mergeSort(int A[],int left,int right,int *cnt){
  int mid;
  if(left+1 < right){
    mid=(left+right)/2;
    mergeSort(A,left,mid,cnt);
    mergeSort(A,mid,right,cnt);
    merge(A,left,mid,right,cnt);
  }


}



int main(){
  int n,i;
  int A[500001];
  int cnt=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);

  mergeSort(A,0,n,&cnt);

  for(i=0;i<n-1;i++)printf("%d ",A[i]);
  printf("%d\n",A[n-1]);

  printf("%d\n",cnt);

  return 0;
}



Measured memory_bytes: 5620
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, const char* argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    string Number;
    cin >> Number;

    int len = Number.size();
    int sum = 0;

    for (int i = 0; i < len; i++) {
        sum += Number.at(i) - '0';
    }

    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

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

    return 0;
}

Measured memory_bytes: 3712
import math
A,B,H,M = map(int,input().split())

c1 = 2 * math.pi * (M / 60)
c2 = 2 * math.pi * ((60*H+M)/720)

dif = abs(c1-c2)
dif = min(dif , 2*math.pi-dif)

#print (c1,c2)
print ( (A**2+B**2-2*A*B*math.cos(dif))**0.5 )


Measured memory_bytes: 62436
#include<stdio.h>
int main(void)
{
        char t,c;
        int n[52],a,b,d;
        for(a=0;a<52;a++){
                n[a]=0;
        }
        scanf("%d",&a);
        for(b=0;b<=a;b++){
                scanf("%c %d%c",&t,&d,&c);
                switch(t){
                        case 'S':
                                n[d-1]=1;
                                break;
                        case 'H':
                                n[d+12]=1;
                                break;
                        case 'C':
                                n[d+25]=1;
                                break;
                        case 'D':
                                n[d+38]=1;
                                break;
                }
        }
        for(a=0;a<52;a++){
                if(n[a]!=1){
                        switch(a/13){
                                case 0:
                                        printf("S %d\n",a%13+1);
                                        break;
                                case 1:
                                        printf("H %d\n",a%13+1);
                                        break;
                                case 2:
                                        printf("C %d\n",a%13+1);
                                        break;
                                case 3:
                                        printf("D %d\n",a%13+1);
                                        break;
                        }
                }
        }
        return 0;
}



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

using namespace std;

int N, A;
int v[51];
long long dp[51][51][2501];

long long solve(int pos, int qt, int sum)
{
	if ( pos == N )
		if ( qt != 0 && sum%qt == 0 && sum/qt == A )
			return 1;
		else if ( qt == 0 && A == 0 )
			return 1;
		else
			return 0;
	if ( dp[pos][qt][sum] != -1 )
		return dp[pos][qt][sum];
	long long & ans = dp[pos][qt][sum];
	ans = 0;
	ans += solve(pos+1, qt, sum) + solve(pos+1, qt+1, sum+v[pos]);
	return ans;
}

main()
{
	memset(dp, -1, sizeof(dp));
	cin >> N >> A;	
	for ( int i = 0 ; i < N ; i++ )
		cin >> v[i];
	cout << solve(0, 0, 0) << "\n";
}


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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int n,d,arr[12][12],ans=0,temp,sum;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    

    cin>>n>>d;
    rep(i,1,n)
        rep(j,1,d)
            cin>>arr[i][j];

    rep(i,1,n-1)
    {
        rep(j,i+1,n)
        {
            sum=0;
            rep(k,1,d)
            {
                sum+=(arr[i][k]-arr[j][k])*(arr[i][k]-arr[j][k]);
            }
            temp=sqrt(sum);
            if(temp*temp==sum)
                ans++;
        }
    }
    cout<<ans;
}


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

const ll MOD = 1000000007;
int main() {
    const int MAXD = 100010;
    int N, T; cin >> N >> T;
    vector<int> A(MAXD + 10);

    vector<int> D(N);
    for(int i=0; i<N; i++) {
        cin >> D[i];
        A[ D[i] ]++;
    }
    sort(D.begin(), D.end());

    for(int i=1; i<MAXD; i++) {
        A[i] += A[i-1];
    }

    int pre = -1, cons = 0;
    ll ans = 1;
    for(int i=0; i<N; i++) {
        if(pre != D[i]) pre = D[i], cons = 0;
        else cons++;

        int C = A[ D[i] - 1 ] - A[ max(0, D[i] - T - 1) ] + cons;
        (ans *= (C + 1)) %= MOD;
    }
    cout << ans << endl;
    return 0;
}



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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define ll long long
#define el '\n'

using namespace std;


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

    ll w,h,x,y;
    cin >> w >> h >> x >> y;
    double a=(double)(w*h)/2;
    
    cout << fixed << setprecision(11);

    if (w%2+h%2>0){
        cout << a << " " << (int)0 << el;
        return 0;
    }

    if (w/2==x && h/2==y){
        cout << a << " " << (int)1 << el;
        return 0;
    }

    cout << a << " " << (int)0 << el;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    static Scanner sc=new Scanner(in);
    public static void main(String[] args) {
        int n=sc.nextInt();
        int[] p=new int[n];
        for (int i = 0; i < n; i++) {
            p[i]=sc.nextInt();
        }
        int ans=0;
        for (int i = 0; i < n - 2; i++)
            if (p[i] + p[i + 1] + p[i + 2] - min(p[i], min(p[i + 1], p[i + 2])) - max(p[i], max(p[i + 1], p[i + 2])) == p[i + 1])
                ans++;
            out.println(ans);
    }
}

Measured memory_bytes: 23636
import java.util.Scanner;

/**
 * Created by User on 2017/02/07.
 */
public class Main {
    public static void main(String[] args) {
        int[] num = new int[4];
        Scanner scn = new Scanner(System.in);

        num[0] = scn.nextInt();
        num[1] = scn.nextInt();
        num[2] = scn.nextInt();
        num[3] = scn.nextInt();

        System.out.println(num[0] * num[1] > num[2] * num[3] ? num[0] * num[1] : num[2] * num[3]);
    }
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	int N, ans=0;
	string s;

	cin >> s;

	int l=0, r=s.length()-1;
	while(l<r){
		if( s[l] == s[r] ) l++, r--;
		else if( s[l] == 'x' ) ans++, l++;
		else if( s[r] == 'x' ) ans++, r--;
		else{
			ans = -1;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

vector<bool> IsPrime;

void sieve(ll max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(ll i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(ll j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

int main(){
    sieve(100000);
    ll Q;
    cin >> Q;
    vector<ll> l(Q,0);
    vector<ll> r(Q,0);
    for(ll i=0;i<Q;i++){
        cin>>l[i]>>r[i]
    ;}  
    vector<ll> until(100001,0);
    for(ll i=2;i<100001;i++){
        until[i]=until[i-1];
        if(IsPrime[i]&&IsPrime[(i+1)/2]&&i%2==1){
            until[i]++;
        }
    ;}
    for(ll i=0;i<Q;i++){
        cout<<until[r[i]]-until[l[i]-1]<<endl;
    ;}

return 0;
}


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

int main() {

  string in;
  stack< long long int > s;

  while( cin >> in ) {
    if ( in == "@" ) break;
    if ( in == "+" ) {

      long long int a = s.top();
      s.pop();
      long long int b = s.top();
      s.pop();
      s.push( a + b );

    }else if ( in == "-" ) {

      long long int a = s.top();
      s.pop();
      long long int b = s.top();
      s.pop();
      s.push( b - a );

    }else if ( in == "*" ) {

      long long int a = s.top();
      s.pop();
      long long int b = s.top();
      s.pop();
      s.push( a * b );

    }else {

      long long int k = 0;
      for ( long long int i = 0; i < in.size(); i++ ) {
	k = k * 10 + in[i] - '0';
      }
      s.push( k );

    }

  }

  cout << s.top() << endl;

  return 0;

}

Measured memory_bytes: 1192
import java.util.Scanner;

public class Main {
	
	public static void printArray(int[] A){
		int n = A.length;
		for(int i=0; i<n-1; i++){
			System.out.print(A[i]+" ");
		}
		System.out.print(A[n-1]+"\n");
	}

	public static void bubbleSort(int[] A){
		int swapTimes = 0;
		for(int n=A.length-1; n>0; n--){
			for(int i=0; i<n; i++){
				if(A[i]>A[i+1]){
					swap(A,i,i+1);
					swapTimes++;
				}
			}
		}
		printArray(A);
		System.out.println(swapTimes);
	}

	private static void swap(int[] A, int a, int b){
		int t = A[a];
		A[a] = A[b];
		A[b] = t;
	}

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] A = new int[n];
		for(int i=0; i<n; i++){
			A[i] = scan.nextInt();
		}

		scan.close();

		bubbleSort(A);
	}
}


Measured memory_bytes: 26348
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    int x = A+B;
    int y = B+C;
    int z = C+A;
    
    System.out.println(Math.min(x,Math.min(y,z)));
  }
}

Measured memory_bytes: 23252