akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[100010];
    rep(i, N) cin >> a[i];
    rep(i, N) a[i] = a[i] % 2;
    rep(i, N){
        if (a[i] % 2 == 1) {
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;


    return 0;
}


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


int main()
{
	int x,y;

	cin >>x;
	cin >>y;

	if(x<y)
		cout <<"a < b"<<endl;

	if(x>y)
		cout <<"a > b"<<endl;

	if(x==y)
		cout <<"a == b"<<endl;

	//while(1);

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){

	int n;
	cin >> n;
	vector<long long int> a(n+1);
	for(int i=0;i<n;i++) cin >> a[i];

	long long int cnt = 0;
	for(int i=0;i<n;i++){
		if( a[i]%2 == 0 ){
			cnt += a[i]/2;
			a[i] = 0;
		}else{
			cnt += a[i]/2;
			a[i] = 1;
			if( a[i+1] != 0 ){
				cnt++;
				a[i] = 0;
				a[i+1]--;
			}
		}

	}
	cout << cnt << endl;

	return 0;
}

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

int main() {
  int N, T; cin >> N >> T;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<int> B(N);
  int max_a = 0;
  for (int i = N-1; i >= 0; i--) {
    max_a = max(max_a, A.at(i));
    B.at(i) = max_a;
  }
  map<int, int> M;
  for (int i = 0; i < N; i++) {
    int p = B.at(i) - A.at(i);
    if (M.count(p)) M[p]++;
    else M[p] = 1;
  }
  auto it = rbegin(M);
  if ((*it).first == 0) cout << 0 << endl;
  else cout << (*it).second << endl;
}

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

int main(){
int h[10];

int a;
int i;
for(i=0; i<10; i++){
cin >> h[i];
}

a=0;
for(i=0; i<10; i++){
if(h[a]<h[i]) a=i;
}
cout << h[a] << endl;

h[a]=0;
a=0;
for(i=0; i<10; i++){
if(h[a]<h[i]) a=i;
}
cout << h[a] << endl;
h[a]=0;
a=0;
for(i=0; i<10; i++){
if(h[a]<h[i]) a=i;
}
cout << h[a] << endl;

return 0;
}

Measured memory_bytes: 3068
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int c = sc.nextInt();
    int[] b = new int[m];
    int[][] a = new int[n][m];
    int sum = 0;
    int flag = 0;
    for(int i=0;i<m;++i){
      b[i] = sc.nextInt();
    }
    for(int i=0;i<n;++i){
      for(int j=0;j<m;++j){
        a[i][j] = sc.nextInt();
        sum+=a[i][j]*b[j];
      }
      flag+=sum+c>0?1:0;
      sum=0;
    }
    System.out.println(flag);
  }
}

Measured memory_bytes: 24148
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 1e5 + 5, mod = (int) 0;

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, x;
    cin >> n >> x;
    long long res = 0;
    int last;
    cin >> last;
    res += max(0, last - x);
    if (last >= x)
        last = x;
    for (int i = 0; i < n - 1; ++i) {
        int cur;
        cin >> cur;
        int val = max(0, cur - (x - last));
        res += val;
        cur -= val;
        last = cur;
    }
    cout << res << endl;
}


Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main()
{
int n,i,j;
cin>>n;
for(j=n;;j++)
{for(i=2;i<=n/2;++i)
{
   if(j%i==0)
    break;
    
    
}
if(i==(n/2)+1)
break;
}
cout<<j;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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 ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int n;
  cin  >> n;
  cout << (n%10==n/100 ? "Yes" : "No") << endl;
  return 0;
} 

Measured memory_bytes: 3636
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
int main()
{
    int n, m;
    cin >> n >> m;

    cout << (n - 1) * (m - 1) << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
    int main(void){
     int a,b,c[100],k,i,j=0;
    scanf("%d%d%d",&a,&b,&k);
    if(a>b) { a=a+b; b=a-b; a=a-b;}
    for(i=1;i<=a;i++){
    if((a%i==0)&&(b%i==0))  {c[j]=i; j++;}}
    printf("%d",c[j-k]);
return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
#define N (1000000000+7)
#define INF (ll)1e16
typedef long long ll;


int main(void){
    ll n;
    cin>>n;
    vector<ll>b(n),a(n+1);
    for(ll i=1;i<=n-1;i++)cin>>b[i];
    for(ll i=2;i<=n-1;i++){
        if(b[i-1]<=b[i]){
            a[i]=b[i-1];
        }
        else{
            a[i]=b[i];
        }
    }
    a[1]=b[1];
    a[n]=b[n-1];
    ll sum=0;
    for(ll i=1;i<=n;i++){
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


set<char> s;

int main(){
	for(int i = 0; i < 3; i++){
		char c;
		cin >> c;
		s.insert(c);
	}
	if(s.size() == 3) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
while True:
    P = list()
    ans = list()
    tans = list()
    m, Mn, Mx = map(int, input().split())
    if m == 0 and Mn == 0 and Mx == 0:
        break
    for i in range(0, m):
        P.append(int(input()))

    for j in range(Mn-1, Mx, 1):
        ans.append(P[j]-P[j+1])
    #print(ans)
    for k in range(0,len(ans)):
        if ans[k] == max(ans):
            tans.append(k)
    #print(tans)
    print(max(tans)+Mn)



Measured memory_bytes: 5612
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1e9 + 7

var ifac, fac []int

func main() {
	var n int
	fmt.Scan(&n)

	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)

	m := make(map[int]int)

	for i := range as {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		as[i] = a
		m[a]++
	}

	var sum int
	for _, v := range m {
		sum += v*(v-1)/2
	}
	for i := range as {
		fmt.Println(sum - (m[as[i]]-1))
	}
}


Measured memory_bytes: 14720
n = int(input())
cnt = [[0] * 19 for i in range(19)]
ans = 0
for i in range(n):
	a = int(float(input()) * 10**9 + 0.5)
	c2, c5 = -9, -9
	while a % 2 == 0:
		c2 += 1
		a //= 2
	while a % 5 == 0:
		c5 += 1
		a //= 5
	cnt[min(c2, 9)][min(c5, 9)] += 1
	if c2 >= 0 and c5 >= 0:
		ans -= 1
for i in range(-9, 10):
	for j in range(-9, 10):
		for x in range(-i, 10):
			for y in range(-j, 10):
				ans += cnt[i][j] * cnt[x][y]
print(ans // 2)

Measured memory_bytes: 9240
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int h = parseInt(sc.next());
		int w = parseInt(sc.next());
		String[] a = new String[h];
		for(i=0;i<h;i++) {
			a[i] = sc.next();
		}
		sc.close();
		PrintWriter pw = new PrintWriter(out);
		for(i = 0; i < w+1; i++) {
			pw.print("#");
		}
		pw.println("#");
		for(i = 0; i < h; i++) {
			pw.print("#");
			pw.print(a[i]);
			pw.println("#");
		}
		for(i = 0; i < w+1; i++) {
			pw.print("#");
		}
		pw.println("#");
		pw.flush();
	}
}


Measured memory_bytes: 20820
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[100010];
int main() 
{
	int N;
	cin >> N;
	A[0] = 0;
	A[N + 1] = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i + 1];
	}
	int sum = 0;
	for (int i = 0; i <= N; i++) {
		sum += abs(A[i + 1] - A[i]);
	}
	for (int i = 0; i < N; i++) {
		int ans = sum;
		ans -= abs(A[i + 1] - A[i]);
		ans -= abs(A[i + 2] - A[i + 1]);
		ans += abs(A[i + 2] - A[i]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <algorithm>
#include <queue>

typedef long long ll;
ll N, M;
int main(){
        scanf("%lld %lld",&N,&M);
        ll ans=1;
        std::deque<ll> q;

        for(ll i = 1; i*i <= M; i++){
                if(M % i == 0){
                        q.push_front(i);
                        q.push_back(M/i);
                }
        }
        std::sort(q.begin(),q.end());
        std::deque<ll>::iterator it = q.begin();
        //while(it != q.end()){
        //      printf("%lld,",*it++);
        //}puts("");
        it = std::lower_bound(q.begin(),q.end(),N);
        //if(*it > N) ans = *it;
        //else        ans = *it;
        printf("%lld\n",M/(*it));
        return 0;
}

Measured memory_bytes: 256
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for _ in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case #{}: {}".format(i, o))


def solve(n, a):
    a.sort(reverse=True)
    comfort = 0
    for i in range(1, len(a)):
        comfort += a[i // 2]

    return comfort


if __name__ == "__main__":
    n = int_in()
    a = arr_in()
    out(solve(n, a))

Measured memory_bytes: 91864
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}



const ll N=1e6+5;

ll dp[N][2];

int main()
{ 

IOS;

string s;cin>>s;

ll n=sz(s);

s='0'+s;
rev(s);


/*

either we can pay some 10^i bills (dp[i][1])

or take them from the banker (dp[i][0])
and pay the val at i'th postion with a higher currency.

*/

for(int i=0;i<=n;i++){
  ll dig=s[i]-'0';
  if(!i){
    dp[i][0]=10-dig;
    dp[i][1]=dig;
    continue;
  }
  dp[i][1]=min(dig+1+dp[i-1][0],dig+dp[i-1][1]);
  dp[i][0]=min(10-dig+dp[i-1][1],9-dig+dp[i-1][0]);
}

cout<<dp[n][1];


//end_routine();

return 0;
 
 }


Measured memory_bytes: 20124
N, K = map(int, input().split())
V = list(map(int, input().split()))
from collections import deque
res=0
for i in range(min(N+1,K+1)):
    for j in range(min(N+1,K+1)-i):
        cur = list()
        v = deque()
        for f in V:
          v.append(-f)
        ans=0
        for p in range(i):
            cur.append(v.popleft())
        for q in range(j):
            cur.append(v.pop())
        cur=sorted(cur,reverse=True)
        #print(cur)
        for n in range(min(K-i-j,len(cur))):
            if cur[n]>0:
                cur[n]=0
            else:
                break
        res = max(-1*sum(cur),res)
print(res)

Measured memory_bytes: 42992
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <string>
#include <queue>
#include <memory>
#include <deque>
#include <set>
#include <unordered_set>
#include <cmath>
#include <list>
#include <cassert>
#include <cstring>

using namespace std;

using big = long long;

const int N = 200;
int p[N], c[N], f[2020];


int main() {
	std::ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int sum = 0;
  m /= 100;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i] >> c[i];
    c[i] /= 100;
    sum += p[i];
  }
  f[0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = sum; j >= 0; --j)  {
      for (int k = 1; k <= p[i]; ++k) {
        int w = k * i + (k == p[i]) * c[i];
        if (j < k) {
          continue;
        }
        f[j] = max(f[j], f[j - k] + w);
      }
    }
  }
  int ans = sum;
  for (int i = 1; i <= sum; ++i) {
    if (f[i] >= m) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000001
#define cmax 10000

int main(){
  int i,n,j;
  int C[cmax];
  unsigned short A[MAX],B[MAX];
  
  scanf("%d",&n);
  
  for( i = 1 ; i <= n ; i++ )
    scanf("%hu",&A[i]);

  for( i = 0 ; i <= cmax ; i++ )
    C[i] = 0;

  for( j = 1 ; j <= n ; j++ )
    C[A[j]]++;

  for( i = 1 ; i <= cmax ; i++ )
    C[i] = C[i] + C[i-1];

  for( j = n ; j > 0 ; j-- )
    {
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }


  for( i = 1 ; i < n ; i++ )
    printf("%d ",B[i]);
  printf("%d\n",B[i]);
  return 0;
}

Measured memory_bytes: 8452
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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 (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}



struct UnionFind
{
  vector<int> uni;
  UnionFind(int n): uni(n+5, -1) {}
  int  root(int x)        { return (uni[x] < 0)? x : uni[x] = root(uni[x]); }
  bool same(int x, int y) { return root(x) == root(y); }
  bool unite(int x, int y){
    if ( (x=root(x)) == (y=root(y)) )return false;
    if ( uni[y] < uni[x] ) swap(x,y);
    uni[x] += uni[y],  uni[y] = x;
    return true;
  }
  int size(int i)     { return (-uni[root(i)]); }
};

inline void solve(){
  
  int n, m;
  int a[100005],b[100005];
  cin >>n >> m;
  FOR(i,m){
    cin >> a[i] >> b[i];
  }
  int Max = n*(n-1)/2;
  int ans[100005]={};
  ans[m]=Max;
  UnionFind uf(n);
  for(int i = m-1;i>=0;i--){
    int x=a[i],y=b[i];
    if(!uf.same(x,y)){      
      ans[i]=ans[i+1]-uf.size(x)*uf.size(y);
      uf.unite(x,y);
    }else{
      ans[i]=ans[i+1] ;
    }

  }
  iFOR(i,1,m+1){
    cout << ans[i] fin;
  }
  
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}



Measured memory_bytes: 4480
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

type SortRune []rune

func (p SortRune)Len() int {
	return len(p)
}

func (p SortRune)Less(i, j int) bool {
	return p[i] < p[j]
}

func (p SortRune)Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(SortRune(r))
	return string(r)
}

func Solve(stdin io.Reader, stdout io.Writer) {
	sc := bufio.NewScanner(stdin)
	sc.Split(bufio.ScanWords)

	buf := make([]byte, 100000)
	sc.Buffer(buf, 100000)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	list := make(map[string]int)

	var num int64

	for i := 0; i < n; i++ {
		sc.Scan()
		s := sc.Text()
		s = SortString(s)
		list[s]++
		num += int64(list[s] - 1)
	}

	/* 出力用 */
	_, _ = fmt.Fprintf(stdout, "%d\n", num)
}

func main() {
	Solve(os.Stdin, os.Stdout)
	return
}

Measured memory_bytes: 12032
a = []
b = []

5.times do
  x = gets.chomp.to_i
  if x % 10 == 0
    a << x
  else
    b << x
  end
end

b.sort_by!{|x| x % 10}

ret = 0
ret += a.inject(:+) unless a.empty?
x = b.shift
ret += x unless x.nil?
b.each do |x|
  ret += (x / 10 + 1) * 10
end
puts ret

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

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

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int n;
ll a[maxn];
ll prt[maxn];

int main(){
    migmig
	cin >> n;
	for(int i = 0 ; i <= n ; i ++){
		cin >> a[i];
	}
    if(n == 0){
		dokme(((a[0] == 1)?1:-1))
	}
    for(int i = n ; i >= 0 ; i --){
		prt[i] = prt[i+1]+a[i];
	}
	ll ans = 0;
	ll cur = 1;
	for(int i = 0 ; i <= n ; i ++){
		ans+=cur;
		if(cur < a[i]){
			dokme(-1);
		}
		cur -= a[i];
		cur = min(cur * 2 , prt[i+1]);
	}
	cout << ans;
    return(0);
}

Measured memory_bytes: 5184
#include <stdio.h>
#include <math.h>

int isprime(int);

int main()
{
  int a, c=0, i, n, buf[10000];

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

  for(i = 0 ; i < n ; i++){
    a = isprime(buf[i]);
    if(a == 1){
      c++;
    }
  }
    
  printf("%d\n",c);
  
  return 0;
}

int isprime(int x)
{
  int i;
  if (x == 2){
    return 1;
  }
  if (x < 2 || x%2 == 0){
    return 0;
  }
  
  i = 3;
  while (i <= sqrt(x)){
    if (x%i==0){
      return 0;
    }
    i = i + 2;
	
  }
  return 1;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const int mod=1e9+7,N=100005;
int fac[N],n,m,ans;
void read(int &x)
{
    x=0;
    int y=1;
    char c=getchar();
    while (c>'9'||c<'0')
    {
        if (c=='-')
            y=-1;
        c=getchar();
    }
    while (c>='0'&&c<='9')
    {
        x=x*10+c-'0';
        c=getchar();
    }
    x*=y;
}
int main()
{
	read(n);
	read(m);
	if (n>m)
		swap(n,m);
	fac[0]=1;
	for (int i=1;i<=m;++i)
		fac[i]=(ll)fac[i-1]*i%mod;
	if (n==m)
		ans=(ll)fac[n]*fac[m]*2%mod;
	else
	{
		if (n+1==m)
			ans=(ll)fac[n]*fac[m]%mod;
		else
			ans=0;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))


A2 = sorted(A)
B2 = sorted(B)
C2 = sorted(C)

A2.append(2000000000)
B2.append(2000000000)

def numadd(up, down):
    array = []
    count = 0
    for i in range(0,N):
        while down[i] > up[count]:
            count = count + 1
            
        array.append(count) #+ last)
    return array

B3 = numadd(A2,B2)
C3 = numadd(B2,C2)

B4 = [B3[0]]
for i in range(0,N-1):
    B4.append(B4[i] + B3[i+1])

ans = 0
for i in range (0,N):
    if C3[i] > 0:
        ans = ans + B4[C3[i]-1]

print(ans)

Measured memory_bytes: 29812
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a%3==0||b%3==0||(a+b)%3==0){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int b, r, g, c, s, t, m;

	while(cin >> b >> r >> g >> c >> s >> t) {
		if(b==0&&r==0&&g==0&&c==0&&s==0&&t==0)
			break;
		m=100;
		m+=80*b+54*r+7*g+2*c;
		t-=(s+5*b+3*r);
		m-=3*t;

		cout << m << endl;
		
	}

	return 0;

}

Measured memory_bytes: 0
from collections import deque

N, M = map(int,input().split())
ac = [0] * N
pena = [0] * N

for a in range(M):
    p,s = input().split()
    
    p = int(p) - 1

    if ac[p]:
        continue
    if s == 'AC':
        ac[p] = 1
    else:
        pena[p] += 1

AC = 0
PENA = 0

for a in range(N):
    AC += ac[a]
    if ac[a]:
        PENA += pena[a]

print(AC,PENA)

Measured memory_bytes: 4852
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sn = new Scanner(System.in);
        int[] list = new int[5];
		for( int i =1; i < 6 ; i++ ){
			int cnt = Integer.parseInt(sn.next());
			if (cnt == 0){
				System.out.println(i);
			}
		}
	}
}



Measured memory_bytes: 35672
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1e9 as usize + 9;

fn main() {
    input! {
        n: usize,
        s: chars,
        t: chars,
    }

    for i in 0..n {
        print!("{}{}", s[i], t[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cmath>
#include <cassert>
#define SIZE 200005

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

char str[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	int A,B,C,D;
	scanf("%d %d %d %d",&A,&B,&C,&D);
	A--,B--,C--,D--;
	scanf("%s",&str);
	if(C<D)
	{
		bool up=true;
		for(int i=B;i<D;i++)
		{
			if(str[i]=='#'&&str[i+1]=='#') up=false;
		}
		for(int i=A;i<C;i++)
		{
			if(str[i]=='#'&&str[i+1]=='#') up=false;
		}
		puts(up?"Yes":"No");
	}
	else
	{
		while(B<C)
		{
			if(str[B-1]=='.'&&str[B+1]=='.') break;
			if(str[B+1]=='#'&&str[B+2]=='#')
			{
				puts("No");
				return 0;
			}
			if(str[B+1]=='#') B+=2;
			else B++;
		}
		if(B>D)
		{
			puts("No");
			return 0;
		}
		bool up=true;
		for(int i=B;i<D;i++)
		{
			if(str[i]=='#'&&str[i+1]=='#') up=false;
		}
		for(int i=A;i<C;i++)
		{
			if(str[i]=='#'&&str[i+1]=='#') up=false;
		}
		puts(up?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A,*B;
  int C[VMAX+1];
  int n,i,j;

  scanf("%d",&n);
  
  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  for(i=0;i<=VMAX;i++) C[i]=0;

  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];

  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 9652
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int PT[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
int QT[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
int RT[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

int main()
{
    int N;
    string tempS;
    cin >> N;
    vector<string> blue;
    REP(i,N)
    {
        cin >> tempS;
        blue.push_back(tempS);
    }
    int M;
    cin >> M;
    vector<string> red;
    REP(i,M)
    {
        cin >> tempS;
        red.push_back(tempS);
    }
    int ans = 0;
    int temp = 0;
    REP(i,N)
    {
        temp = 0;
        REP(j,N)
        {
            if(blue[i] == blue[j]) ++temp;
        }
        REP(j,M)
        {
            if(blue[i] == red[j]) --temp;
        }
        ans = max(ans,temp);
    }

    cout << ans << endl;
}

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

int main() {
int a, b;
string op;
while(1) {
cin >> a >> op >> b;
if (op == "+") {
cout << a + b << endl;
} else if ( op == "-") {
cout << a - b << endl;
} else if (op == "/") {
cout << a / b << endl;
} else if ( op == "*") {
cout << a * b << endl;
}else {
break;
}}return 0;}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
		int N,Flg=0;
    	cin >> N;
    	for (int i=1; i<10; i++){
    		for (int j=1; j<10; j++){
    			if (N == i*j){
    				Flg = 1;
    			}
    		}
    	}
    	if (Flg == 1){
    		cout << "Yes" << endl;
    	}
    	else {
    		cout << "No" << endl;
    	}
    }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <set>
#include <map>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
int main(){
    set<string> s;
    map<string,int> mp;
    int max_s = 0;
    int n;
    cin >> n;
    rep(i,n){
        string ss;
        cin >> ss;
        mp[ss]++;
        max_s = max(max_s,mp[ss]);
        s.insert(ss);
    }
    set<string> ans;
    for(set<string>::iterator itr = s.begin();itr!=s.end();itr++){
        if(mp[*itr]==max_s) ans.insert(*itr);
    }
    for(set<string>::iterator itr = ans.begin();itr!=ans.end();itr++) cout << *itr << endl;
}


Measured memory_bytes: 43904
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;

void reconstruct_tree
(vector<pair<int, int> >& nodes, 
 const int s, const int t, const int r,
 const vector<int>& preo,  const vector<int>& inv_preo,
 const vector<int>& ino,   const vector<int>& inv_ino)
{
  // r is in ino[s,t)
  int left_subtree_size  = inv_ino[r] - s;
  int right_subtree_size = t - inv_ino[r] -1;
  if(left_subtree_size > 0){
    nodes[r].first = preo[inv_preo[r]+1];
    reconstruct_tree(nodes, s, inv_ino[r], nodes[r].first,
		     preo, inv_preo, ino, inv_ino);
  }
  else{
    nodes[r].first = -1;
  }

  if(right_subtree_size > 0){
    nodes[r].second = preo[inv_preo[r]+left_subtree_size+1];
    reconstruct_tree(nodes, inv_ino[r]+1, t, nodes[r].second,
		     preo, inv_preo, ino, inv_ino);
  }
  else{
    nodes[r].second = -1;
  }
}
 
void print_preorder(const vector<pair<int, int> >& nodes, const int r){
  //cout << '?' << endl;
  if(r<0) return;
  //cout << '?' << endl;
  cout << ' ' << r;
  print_preorder(nodes, nodes[r].first);
  print_preorder(nodes, nodes[r].second);
}
 
void print_inorder(const vector<pair<int, int> >& nodes, const int r){
  if(r<0) return;
  print_inorder(nodes, nodes[r].first);
  cout << ' ' << r;
  print_inorder(nodes, nodes[r].second);
}
   
 
void print_postorder(const vector<pair<int, int> >& nodes, const int r, int geta, bool& first_print){
  if(r<0) return;
  print_postorder(nodes, nodes[r].first, geta, first_print);
  print_postorder(nodes, nodes[r].second, geta, first_print);
  
  cout << (first_print ? "": " ")  << (r+geta);
  first_print = false;
}
 
int main(){
  std::ios_base::sync_with_stdio(false);
 
  int n;
  cin >> n;
  vector<pair<int, int> > nodes(n);
  vector<int> preo(n); //0 .. n-1
  vector<int> inv_preo(n);
  vector<int> ino(n);  //0 .. n-1
  vector<int> inv_ino(n);
 
  for(int i=0; i<n; ++i){
    int v;
    cin >> v;
    preo[i] = v-1;
    inv_preo[v-1] = i;
  }
  for(int i=0; i<n; ++i){
    int v;
    cin >> v;
    ino[i] = v-1;
    inv_ino[v-1] = i;
  }
  
  reconstruct_tree(nodes, 0, nodes.size(), preo[0],
		   preo, inv_preo, ino, inv_ino);
  
  bool fp = true;
  print_postorder(nodes, preo[0], 1, fp); cout << endl; 
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, vs, n, m) vector<vector<T>> vs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cin(int, m);
    Cout((m*1900 + (n-m)*100) << m);
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
setrecursionlimit(10**6)
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

def judge(x,y,a,bit):
    for i in range(len(a)):
        if bit&(1<<i):
            for j in range(a[i]):
                if ((bit>>x[i][j])&1)^y[i][j]:
                    return False
    return True

n = I()
a = []
x = []
y = []
for i in range(n):
    A = I()
    a.append(A)
    xt = []
    yt = []
    for _ in range(A):
        tmp = LI()
        xt.append(tmp.pop(0)-1)
        yt.append(tmp.pop(0))
    x.append(xt)
    y.append(yt)

ans = 0
length = 2**n
for i in range(length):
    result = judge(x,y,a,i)
    if result:
        ans = max(ans,bin(i).count('1'))
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r,g,b,n,k;
  k=0;
  cin>>r>>g>>b>>n;
  for(int m=0; m*r<=n; m++){
    
    for(int i=0; m*r+i*g<=n; i++){
     
      
      if((n-m*r-i*g)%b==0){
        k=k+1;
        
      }
    }
  }
  cout<<k;
}

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


//using ll = long long;
int ASC( void *a,  void *b) {
	return strcmp(*(const char **)a, *(const char **)b);//降順
}
int GCD(int a, int b) {	//最大公約数
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int min(double a, double b ) {
	if (a < b) {
		return a;
	}
	else
		return b;
}
int max(int a, int b) {
	if (a < b)
		return b;
	else
		return a;
}
int main(void)
{
	char s[200001], s2[200001];
	long long int count = 0;
	scanf("%s%s",s,s2);
	for (int i = 0; i < strlen(s); i++) {
		if (s[i] != s2[i])
			count++;
	}
	printf("%lld",count);
	return 0;
}

Measured memory_bytes: 2104
#include <stdio.h>
#include <string.h>

int main(void)
{
	int i,j;
	char s[11];
	char end[1];
	end[0]='\0';
	scanf("%s",s);
	strcat(s,end);
	for(i=0;i<=9;i++)
		{if(s[i]=='B'&& i != 0)
			{j=i;
			i-=2;
			fprintf(stderr,"i!=0で%s→",s);
			for(j;j<=9;j++)
				{
			 	 s[j-1]=s[j+1];
				 s[j]='\0';
			 	 s[j+1]='\0';
				}
			fprintf(stderr,"%s\n",s);
			}				 
		if(s[i]=='B' && i == 0)
			{j=0,i--;
			fprintf(stderr,"i==0で%s→",s);
			for(j;j<=8;j++)
				{s[j]=s[j+1];
				 s[j+1]='\0';
				}
			fprintf(stderr,"%s\n",s);
			}
		}
	printf("%s\n",s);
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	
	bool flag = true;
	int st = 0, sx = 0, sy = 0;
	for(int i=0; i<n; i++){
		int t, x, y;
		cin >> t >> x >> y;
		int d = (x - sx) + (y - sy);
		if(t - st < d) flag = false;
		else if(t - st != d && (t - st + d) % 2) flag = false;
	}
	
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main{ 
public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int t = Integer.parseInt(str);
         int h = t/3600;
          int m = (t%3600)/60;
           int s = (t%3600)%60;
         System.out.println(h + ":" + m + ":" + s);       
 }
}
        

Measured memory_bytes: 17056
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    String s;

    private void solve() {
        try {
            s = sc.next();
            Boolean former, latter;

            int formerS = Integer.parseInt(s.substring(0, 2));
            int latterS = Integer.parseInt(s.substring(2, 4));


            former = formerS <= 12 && formerS > 0;
            latter = latterS <= 12 && latterS > 0;

            if (former && latter) {
                System.out.println("AMBIGUOUS");
            } else if (former && !latter) {
                System.out.println("MMYY");
            } else if (!former && latter) {
                System.out.println("YYMM");
            } else {
                System.out.println("NA");
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    long long X, K, D;
    while (cin >> X >> K >> D) {
        X = abs(X);
        long long q = X / D;
        if (q >= K) {
            cout << X - D * K << endl;
        }
        else {
            long long r1 = X % D;
            long long r2 = r1 - D;
            bool one = true, two = true;
            long long q1 = (X - r1) / D;
            long long q2 = (X - r2) / D;
            long long res = 1LL<<60;
            if (q1 <= K && (K - q1) % 2 == 0) chmin(res, r1);
            if (q2 <= K && (K - q2) % 2 == 0) chmin(res, abs(r2));

/*
            COUT(K);
            COUT(r1);
            COUT(r2);
            COUT(q1);
            COUT(q2);
            */

            cout << res << endl;
        }
    }
}

















Measured memory_bytes: 3644
<?php
fscanf(STDIN, '%d %d %d', $a, $b, $c);

if ($c-$a-$b <= 0) {
  echo 'No';
  exit;
}

if (4*$a*$b < pow(($c-$a-$b), 2)) {
  echo 'Yes';
} else {
  echo 'No';
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL A,B;
  cin>>A>>B;
  if(A<=5){
    cout << 0 << endl;
  }else
  if(A<=12){
    cout << B / 2 << endl;
  }else{
    cout << B << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  ll W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << 1.0 * W * H / 2.0 << ' '
       << ((x == W-x && y == H-y) ? 1 : 0) << endl;
  return 0;
}


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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int w, h; cin >> w >> h;
  long long p[w + 1];
  for (int i = 0; i < w; i++) cin >> p[i];
  long long q[h + 1];
  for (int i = 0; i < h; i++) cin >> q[i];
  p[w] = q[h] = 2e9;
  sort(p, p + w);
  sort(q, q + h);
  int i = 0, j = 0;
  long long res = 0;
  while (i < w or j < h) {
    if (p[i] < q[j]) {
      res += (h + 1 - j) * p[i];
      i++;
    } else {
      res += (w + 1 - i) * q[j];
      j++;
    }
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,h,w,f[N<<1],si[N<<1];
bool vis[N<<1];
struct node
{
    int a,x,y;
    bool operator<(const node&o)const
    {
        return a>o.a;
    }
}a[N];
int getf(int x){return f[x]==x?f[x]:f[x]=getf(f[x]);}
int main()
{
    scanf("%d%d%d",&n,&h,&w);
    for(int i=1;i<=n;i++) scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].a),a[i].y+=h;
    sort(a+1,a+1+n);
    for(int i=1;i<=h+w;i++)
        f[i]=i,si[i]=1;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        int fx=getf(a[i].x),fy=getf(a[i].y);
        if(fx!=fy){f[fy]=fx;si[fx]+=si[fy];}
        if(si[fx])
        {
            ans+=a[i].a;
            si[fx]--;
        }
    }
    printf("%lld\n",ans);
}


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

#define DEBUG(x) cerr << #x << " = " << x << endl

int main()
{
    int n, p;
    while (cin>>n>>p, n||p) {
        int get[50]={0}, stone=p, win=-1, i=0;
        while (1) {
            if (stone==0) {
                stone+=get[i];
                get[i]=0;
            } else {
                stone--;
                get[i]++;
                if (stone==0) {
                    for (int j=0; j<n; j++) {
                        if (get[j] != 0 && i!= j){
                          goto end;
                        }
                    }
                    win = i; break;
                end:;
                }
            }
            i= (i+1)%n;
        }
        cout << win << endl;
    }
    return 0;
}

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

using namespace std;

// https://atcoder.jp/contests/abc072/tasks/abc072_b
// 200点

int main()
{
    string s;
    cin >> s;

    string ans = "";
    for (int i = 0; i < s.size(); i += 2)
    {
        ans += s[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main() {
  int i, j, max, count=0, num[6];
  
  for(i=0; i<6; i++) {
  	scanf("%d", &num[i]);
  }
  max = num[5];
  
  for(i=0; i<5; i++) {
    for(j=1; j<6; j++) {
      if((num[j]-num[i]) > max) count++;
    }
  }
  if(count > 0) printf(":(");
  else printf("Yay!");
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

string ans, s;
string table[] = { "afkpuz", "bglqv.",
"chmrw?", "dinsx!", "ejoty " };

int main(){
	while (cin >> s){
		bool f = 0;
		ans = "";
		if (s.size() % 2 != 0){
			cout << "NA" << endl;
			continue;
		}
		if (s.size() == 0)cout << "NA" << endl;
		for (int i = 0; i < s.size(); i += 2){
			if (s[i]>'6' || s[i]<'1' || s[i + 1]>'5' || s[i] < '1'){
				f = 1;
				break;
			}
			ans += table[s[i + 1] - '1'][s[i] - '1'];
		}
		if (f)cout << "NA" << endl;
		else cout << ans << endl;
		ans.clear();
	}
}

Measured memory_bytes: 1196