akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	ll k;
	cin >> k;
	cout << a[0]+a[1]+a[2]*(1<<k);
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,k,a,li[200010]={};
vector<int> vec;

int main(){
	cin >> n >> k;
	REP(i,0,n) cin >> a,li[a]++;
	int c=0;
	REP(i,0,n+1) if(li[i]) c++,vec.push_back(li[i]);
	sort(vec.begin(), vec.end());
	
	if(k>c) cout << 0 << endl;
	else{
		int s=0;
		REP(i,0,c-k) s+=vec[i];
		cout << s << endl;
	}
	return 0;
}



Measured memory_bytes: 2168
sa = list(reversed(input()))
sb = list(reversed(input()))
sc = list(reversed(input()))

turn = 'a'

while True:
    if turn == 'a':
        turn = sa.pop()
    elif turn == 'b':
        turn = sb.pop()
    else:
        turn = sc.pop()
    if (turn == 'a' and not sa) or (
            turn == 'b' and not sb) or (turn == 'c' and not sc):
        break

print(turn.upper())


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int N;
  int check=0;
  cin >> N;
  for(lint i=1;i<=3500;i++){
    for(lint j=1;j<=3500;j++){
      lint up=N*i*j,down=4*i*j-N*(i+j);
      if(down>0 && up%down==0){
        cout << i << " "  << j << " " << up/down << endl;
        check=1;
        break;
      }
    }
    if(check) break;
  }
}

Measured memory_bytes: 256
#include <iostream>
 using namespace std;
 int main(){
  int a,b,c;
   cin>>a>>b>>c;
   if((a-b)*(b-c)*(c-a)==0&&(a==b)+(b==c)+(c==a)==1){
   cout<<"Yes"<<endl;
   }
   else{
   cout<<"No"<<endl;
   }
}


Measured memory_bytes: 256
def main():
  n, m = map(int, input().split())
  g = [[-1]*n for _ in range(m)]
  for i in range(m):
    s = list(map(int, input().split()))
    for j in s[1:]:
      g[i][j-1] = 1
  p = list(map(int, input().split()))

  ans = 0
  for i in range(2**n):
    s = [0]*n
    for j in range(n):
      if ((i >> j) & 1):
        s[j] = 1
    
    flag = True
    for j in range(m):
      cnt = 0
      for k in range(n):
        if g[j][k] == s[k]:
          cnt += 1
      if cnt % 2 != p[j]:
        flag = False
    if flag:
      ans += 1
  
  print(ans) 

if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int table[11][11]={0};
		if(n==0)break;
		for(int i=0,in;i<n;++i){
			for(int j=0;j<n;++j){
				cin>>in;
				table[i][j]=in;
				table[n][j]+=in;
				table[i][n]+=in;
			}
		}
		for(int i=0;i<n;++i)table[n][n]+=table[n][i];
		for(int i=0;i<n+1;++i){
			for(int j=0;j<n+1;++j)printf("%5d",table[i][j]);
			cout<<"\n";
		}
	}
	return 0;
}

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

int main() {
  int n; cin >> n;
  int a[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }

  bool b[n][n] = {};
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      if (i == k) continue;
      for (int j = 0; j < n; j++) {
        if (i == j || j == k) continue;
        if (a[i][j] > a[i][k] + a[k][j]) {
          cout << -1 << endl;
          return 0;
        }
        if (a[i][j] == a[i][k] + a[k][j]) b[i][j] = true;
      }
    }
  }

  long long ans = 0;
  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j < n; j++) {
      if (!b[i][j]) ans += a[i][j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int hasValue(int, int);

int S[10000];
int T[500];

int main() {
  int n, q, i, num, cnt = 0;

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

  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &num);
    if (hasValue(n, num)) cnt++;
  }

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

  return 0;
}

int hasValue(int n, int num) {
  int i;
  for (i = 0; i < n; i++) {
    if (S[i] == num) return 1;
  }
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

const int INF = 1001001001;

int main()
{
    int n;
    cin >> n;
    int mi = 810, mx = -810;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
        mi = min(mi, a[i]);
        mx = max(mx, a[i]);
    }

    if(mi == mx) {
        cout << 0 << endl;
        return 0;
    }

    int ans = INF;
    for(int i = mi; i <= mx; i++) {
        int t = 0;
        rep(j, n) {
            t += (a[j] - i) * (a[j] - i); 
        }
        ans = min(ans, t);
    }

    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn=15,maxm=1e4+5;
int n,m,ans,a[maxn][maxm],b[maxn];
int cal(){
	int i,j,ans=0,sum;
	for (i=0;i<m;i++){
		sum=0;
		for (j=0;j<n;j++) sum+=a[j][i]^b[j];
		sum=max(sum,n-sum);
		ans+=sum;
	}
	return ans;
}
void dfs(int p){
	if (p==n){
		ans=max(ans,cal());
		return;
	}
	b[p]=0; dfs(p+1);
	b[p]=1; dfs(p+1);
}
int main(){
	int i,j;
	while (scanf("%d%d",&n,&m)&&n&&m){
		for (i=0;i<n;i++) for (j=0;j<m;j++) scanf("%d",&a[i][j]);
		ans=0;
		dfs(0);
		printf("%d\n",ans);
	}
	return 0;
}


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

int ar[100005][3];
long long int n;
long long int dp[100005][3];
long long int h;
int temp;

long long int solve(int index,int k){
    if(index == n)
        return 0;
    if(dp[index][k] != -1)
        return dp[index][k];
    dp[index][k] = (max((ar[index][(k+1)%3]+solve(index+1,(k+1)%3)), (ar[index][(k+2)%3]+solve(index+1,(k+2)%3))));
    return dp[index][k];
}

int main(){
    cin >> n;
    h = 0;
    for(int i=0;i<100005;i++){
        for(int j=0;j<3;j++)
            dp[i][j] = -1;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++)
            cin >> ar[i][j];
    }
    for(int i=0;i<3;i++){
        h = max(h,ar[0][i]+solve(1,i));
    }
    cout <<  h << endl;
}


Measured memory_bytes: 8448
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    auto B = aryread();
    long sum;
    auto A = new long[](N);
    A[] = long.max;
    foreach (i; 0 .. N - 1)
    {
        A[i] = A[i].min(B[i]);
        A[i + 1] = A[i + 1].min(B[i]);
    }
    writeln(A.sum());
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#define SZ(x) ((int)x.size())
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back

using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);

int n, m;
vector<int> adj[MAXN];
int root, deg[MAXN];
vector<int> radj[MAXN];

void read()
{
	cin >> n >> m;
	for(int i = 0; i < n - 1 + m; i++)
	{
		int u, v;
		cin >> u >> v;
		adj[u].pb(v);
		deg[v]++;
		radj[v].pb(u);
	}
}

bool visited[MAXN];
int par[MAXN];

void dfs(int u, int pr)
{
	visited[u] = true;
	par[u] = pr;

	for(int v: adj[u])
		deg[v]--;

	for(int v: adj[u])
		if(!visited[v] && deg[v] == 0)
			dfs(v, u);
}

void solve()
{
	for(int i = 1; i <= n; i++)
		if(!deg[i]) root = i;

	dfs(root, 0);

	for(int i = 1; i <= n; i++)
		cout << par[i] << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 62848
#include <iostream>

using namespace std;

int main()
{
  int N, M, X;
  std::cin >> N >> M >> X;

  int cost_big = 0, cost_small = 0;
  
  for (int m=0; m<M; ++m) {
    int i;
    cin >> i;
    
    if (i > X)
      ++cost_big;
    else
      ++cost_small;
  }

  std::cout << min(cost_big,cost_small) << std::endl;
  
  return 0;
}


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

#define pb push_back
#define mp make_pair
#define inf 1000000000
#define mod 1000000007

vector<int> primes;
void sieve()
{
    vector<int> a(1000000,0);
    for(int u=2;u<=1000000;u++)
    {
        if(a[u])continue;
        for(int i=2*u;i<=1000000;i+=u)a[i]=u;
    }
    for(int i=2;i<=1000000;i++)
    {
        if(!a[i])primes.pb(i);
    }
}

int gcd(int a, int b)
{
    while(1)
    {
        if(a==0)return b;
        b%=a;
        if(b==0) return a;
        a%=b;
    }
}
int lcm(int a, int b)
{
    int g=gcd(a,b);
    return ((a*b)/g);
}

int digitCount(int n)
{
    int c=0;
    while(n!=0)
    {
        c+=n%10;
        n/=10;
    }
    return c;
}

int parseInt(string str)
{
    int a=0;
    int l=str.length();
    for(int i=0;i<l;i++)
    {
        a*=10;
        a+=str[i]-48;
    }
    return a;
}

long long parseLong(string str)
{
    long long a=0;
    int l=str.length();
    for(int i=0;i<l;i++)
    {
        a*=10;
        a+=str[i]-48;
    }
    return a;
}

int main()
{
    int n;
    vector<int> v;
    //vector<int> s;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        v.pb(a);
    }
    if(n%2==0)
    {
         for(int i=0,j=n;i<n/2;i++,j-=2)
        {
        cout<<v[j-1]<<" ";
        }
        for(int i=0,j=1;i<n/2;i++,j+=2)
        {
            cout<<v[j-1]<<" ";
        }
    }
    else
    {
         for(int i=0,j=n;i<n/2+1;i++,j-=2)
        {
        cout<<v[j-1]<<" ";
        }
        for(int i=0,j=2;i<n/2;i++,j+=2)
        {
            cout<<v[j-1]<<" ";
        }
    }

    //for(int i=0;i<n;i++)cout<<s[i]<<" ";
}


Measured memory_bytes: 3060
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial, cos, radians
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

a, b, h, m = Is()
c = h*(360/12) + m*(30/60)
d = m*(360/60)
ans = sqrt(a**2+b**2-2*a*b*cos(radians(abs(c-d))))
print(ans)


Measured memory_bytes: 73032
#include <bits/stdc++.h>
using namespace std;
int main(){
     int n;
     long long a[100005];
     cin >> n;
     long long ans=0;
     for (int i=1;i<=n;i++){
        cin >> a[i];
        ans+=a[i];
     }
     if (ans%2==0) cout << "YES\n";
     else cout << "NO\n";
}

Measured memory_bytes: 1024
//sieu nhan
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inp "test.inp"
#define out "test.out"
#define oo 100005
#define inf 1e15
#define mod 1000000007
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define y1 hungdzno1
int n,k,a[oo],f[oo];
void nhap(){
  cin>>n>>k;
  for(int i=1;i<=n;++i){
    cin>>a[i];
    if(i>1) f[i]=inf;
  }
}
void xuly(){
  for(int i=1;i<=n;++i) for(int j=i;j>=max(i-k,(int)(1));--j) f[i]=min(f[i],f[j]+abs(a[i]-a[j]));
  cout<<f[n];
}
main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //freopen(inp,"r",stdin);
  //freopen(out,"w",stdout);
  nhap();
  xuly();
}


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

using namespace std;

int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    bool fl=false;
    if (n%2==1) {
        cout<<"No";
        return 0;
    }
    for (int i=1; i<=n/2; i++)
    {
      if (s[i-1]!=s[n/2+i-1]) fl=true;
    }
    if (!fl) cout<<"Yes"; else cout<<"No";
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
import bisect
from logging import getLogger, StreamHandler, DEBUG, WARNING
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
# handler.setLevel(WARNING)
# logger.setLevel(WARNING)
logger.addHandler(handler)
def main():
    x, y = getList()
    ans = 0
    while(True):
        if x <= y:
            ans += 1
            x *= 2
        else:
            break

    print(ans)
if __name__ == "__main__":
    main()

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

int main(int argc, char **argv)
{
	int A1, A2, A3;
	scanf("%d %d %d", &A1, &A2, &A3);
	if ((A1 + A2 + A3) < 22)
		printf("win\n");
	else
		printf("bust\n");
	return 0;
}


Measured memory_bytes: 128
X,Y=list(map(int, input().split()))
a=(2*X-Y)//3
b=(2*Y-X)//3
if not (2*a+b==X and a+2*b==Y and a>=0 and b>=0):
    print(0)
    exit()

C=10**9+7
A=1
B=1
D=1
for i in range(a):
    A*=i+1
    A=A%C
for j in range(b):
    B*=j+1
    B=B%C
for k in range(a+b):
    D*=k+1
    D=D%C

D*=pow(A,C-2,C)
D*=pow(B,C-2,C)
print(D%C)

Measured memory_bytes: 64500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 100000 + 5;
// ------------------------------------
vector<int> v;
// ------------------------------------
// 1 is tru

int main() {
  string s, t, subs;
  int a = 0;
  cin >> s >> t;
  v.push_back(t.length());

  for (int i = 0; i < s.length(); i++) {
    for (int j = 0; j < t.length(); j++) {
      if (s[i] == t[j]) {
        if (i - j >= 0 && i - j + t.length() <= s.length()) {
          subs = s.substr(i - j, t.length());
          for (int k = 0; k < t.length(); k++) {
            if (subs[k] != t[k]) {
              a++;
            }
          }
          v.push_back(a);
          a = 0;
        }
      }
    }
  }
  cout << *min_element(v.begin(), v.end()) << endl;
}


Measured memory_bytes: 4136
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;


int main() {
	int n;
	string s, t;
	deque<char> ans;
	cin >>n>> s >> t;
	ff(i, 0, n) {
		ans.push_back(s[i]);
		ans.push_back(t[i]);
	}
	while (!ans.empty()) {
		cout << ans.front();
		ans.pop_front();
	}
	return 0;
}

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

int main(){
    string n;
    cin >> n;
    reverse(n.begin(),n.end());
    if (n[0]=='3'){
        cout << "bon" << endl;
        return 0;
    }
    
    if (n[0]=='0' || n[0]=='1' || n[0]=='6' || n[0]=='8'){
        cout << "pon" << endl;
        return 0;
    }
    
    cout << "hon" << endl;
}

Measured memory_bytes: 3624
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)

solve :: Int -> Int -> Int
solve c n
    | c * 2 > n = c
    | otherwise = solve (c * 2) n

main :: IO ()
main = do
    n <- fst . fromJust . BS.readInt <$> BS.getLine
    print $ solve 1 n


Measured memory_bytes: 380
N=int(input())
A=list(map(int,input().split()))

D={0:1}
S=0
for i in range(N):
    S+=A[i]
    if S in D:
        D[S]+=1
    else:
        D[S]=1

K=0
for a in D:
    K+=(D[a]*(D[a]-1))//2

print(K)


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

const ll mod=(1e+9)+7;
const ll inf=1e+16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

  ll n;
  cin >> n;
  ll d=0,s=0;
  rep(i,0,n){
   ll a,b;
    cin >> a >> b;
    d+=b;
    s+=a*b;
  }
 cout << (d-1)+(s-1)/9 << endl;
}


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

int main() {
 string S,T;cin>>S>>T;
 UL ans=0;
 rep(i,S.size())
  if(S[i]!=T[i]) ans++;
 cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 3924
import sys
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
plus, minus = 0, 0

if n == 1:
    if a[0] <= b[0]:
        print('Yes')
    else:
        print('No')
    sys.exit()

for i, j in zip(a, b):
    num = j-i
    if num >= 0:
        plus += num//2
    else:
        minus -= num
        
if plus >= minus:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 10596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define INF 1000000000000000000
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define x first 
#define y second
const int maxx = 1000006;
const int maxlog = 20;
const ll mod = 1000000007;

int main() {
    IOS
    int A, B;
    cin >> A >> B;
    cout << (A <= 2 * B ? 0 : A - (2 * B));
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{   
    int n, m;

    do {
        cin >> n >> m;
    } while ((n < 1 || n > 100) || (m < 1 || m > 100));

    int** A = new int*[n];
    int** b = new int*[m];

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

    for (int i = 0; i < m; i++) {
         b[i] = new int[1];
    }
  
    for (int i = 0; i < n; i++) {
         for (int j = 0; j < m; j++) {
	      do {
                  cin >> A[i][j];
              } while (A[i][j] < 0 || A[i][j] > 1000);
         }
    }

    for (int i = 0; i < m; i++) {
         for (int j = 0; j < 1; j++) {
              do {
                  cin >> b[i][j];
              } while (b[i][j] < 0 || b[i][j] > 1000);
         }
    }

    int** c = new int*[n];
 
    for (int i = 0; i < n; i++) {
         c[i] = new int[1];
    }  

    for (int i = 0; i < n; i++) {
         for (int j = 0; j < 1; j++) {
	      c[i][j] = 0;
         }
    }

    for (int i = 0; i < n; i++) {
         for (int j = 0; j < m; j++) {
	      c[i][0] += A[i][j] * b[j][0];
	 }
    }
      
    for (int i = 0; i < n; i++) {
         for (int j = 0; j < 1; j++) {
              cout << c[i][j] << endl;
         }
    }

    for (int i = 0; i < n; i++) {
         delete[] A[i];
    }

    delete[] A;
        
    for (int i = 0; i < m; i++) {
         delete[] b[i];
    }

    delete[] b;
    
    for (int i = 0; i < n; i++) {
         delete[] c[i];
    }

    delete[] c;
        
    return (0);
}

Measured memory_bytes: 1244
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

public class Main {
  public static void main(String[] args)throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = new String[n];
    Set<String> set = new HashSet<>();
    int count = 0;
    for(int i=0; i<n; i++) {
      set.add(in.readLine());
    }
    System.out.println(set.size());
  }
}

Measured memory_bytes: 65216
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)

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

using namespace std;
using vi=vector<int>;
using vii=vector<vi>;

int main(void){
	int N;
	while(cin>>N,N) {
		int W, H; cin>>W>>H;
		vii m(H, vi(W, 0));
		rep(i,N) {
			int x, y; cin>>x>>y;
			x--; y--;
			m[y][x] = 1;
		}
		int S, T; cin>>S>>T;
		int res = 0;
		rep(h,H-T+1) rep(w,W-S+1) {
			int tmp = 0;
			rep(_h,h,h+T) rep(_w,w,w+S)
				tmp += m[_h][_w];
			chmax(res, tmp);
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  int k;
  cin >> k;
  int a, b;
  cin >> a >> b;
  bool ok = false;
  for(int i = a; i <= b; ++i) {
    if (i%k==0) {
      ok = true;
      break;
    }
  }
  if(ok) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3592
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
    	String t = sc.nextLine();
    	if(t.startsWith(s) && t.length() == s.length() + 1){
    		System.out.println("Yes");
    	}else {
    		System.out.println("No");
    	}
    }
}

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

using namespace std;

const int MAX_V = 210;
const int INF = 1000000;

struct Edge {
    int to, cap, rev;  //行き先、容量、逆辺
    Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
};

vector<Edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap) {
    G[from].push_back(Edge(to, cap, G[to].size()));
    G[to].push_back(Edge(from, 0, G[from].size() - 1));
}

int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        Edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t) {
    int flow = 0;
    while (1) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		string a;
		cin >> a;
		for (int j = 0; j < W; j++) {
			if (a[j] == 'S') {
				add_edge(0, i + 1, INF);
				add_edge(0, H + j + 1, INF);
			} else if (a[j] == 'T') {
				add_edge(i + 1, H + W + 1, INF);
				add_edge(H + j + 1, H + W + 1, INF);
			} else if (a[j] == 'o') {
				add_edge(i + 1, H + j + 1, 1);
				add_edge(H + j + 1, i + 1, 1);
			}
		}
	}
	int ans = max_flow(0, H + W + 1);
	cout << (ans >= INF ? -1 : ans) << endl;
	return 0;
}

Measured memory_bytes: 896
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const EMPTY: char = '.';
const MINE: char = '#';

fn main() {
    let h: usize = read();
    let w: usize = read();

    let mut s: Vec<Vec<char>> = (0..h)
        .map(|_| read::<String>().chars().collect())
        .collect();

    for i in 0..h {
        for j in 0..w {
            if s[i][j] == EMPTY {
                let mut cnt: u32 = 0;

                if i >= 1    && j >= 1     && s[i - 1][j - 1] == MINE {
                    cnt += 1;
                }
                if i >= 1                  && s[i - 1][j]     == MINE {
                    cnt += 1;
                }
                if i >= 1    && j + 1 < w  && s[i - 1][j + 1] == MINE {
                    cnt += 1;
                }

                if               j >= 1    && s[i][j - 1]     == MINE {
                    cnt += 1;
                }
                if               j + 1 < w && s[i][j + 1]     == MINE {
                    cnt += 1;
                }

                if i + 1 < h && j >= 1     && s[i + 1][j - 1] == MINE {
                    cnt += 1;
                }
                if i + 1 < h               && s[i + 1][j]     == MINE {
                    cnt += 1;
                }
                if i + 1 < h && j + 1 < w  && s[i + 1][j + 1] == MINE {
                    cnt += 1;
                }

                s[i][j] = std::char::from_digit(cnt as u32, 10).unwrap();
            }
        }
    }

    for i in 0..h {
        let mut string = String::new();
        string.extend(s[i].iter());
        println!("{}", string);
    }
}


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

int main() {
	int n;
	long long l[100];
	
	cin >> n;
	l[0] = 2;
	l[1] = 1;
	for (int i = 2; i <= n; i++) l[i] = l[i - 1] + l[i - 2];
	cout << l[n] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    int N;
    cin>>N;
    vector<ll>ans(N,0);
    for(ll i=1;i*i<=N;i++){
        for(ll j=i;j*j<=N;j++){
            for(ll k=j;k*k<=N;k++){
                ll Z=i*i+j*j+k*k+i*j+j*k+k*i;
                if(Z<=N){
                    if(i!=j&&j!=k&&k!=i){
                        ans[Z-1]+=6;
                    }
                    else if(i==j&&j==k){
                        ans[Z-1]+=1;
                    }
                    else{
                        ans[Z-1]+=3;
                    }
                }
            }
        }
    }
    for(int i=0;i<N;i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 3704
def main():
    SA=list(input())
    SB=list(input())
    SC=list(input())
    c=SA.pop(0)
    while True:
        if c=='a':
            if len(SA)==0:
                print('A')
                break
            c=SA.pop(0)
        elif c=='b':
            if len(SB)==0:
                print('B')
                break
            c=SB.pop(0)
        elif c=='c':
            if len(SC)==0:
                print('C')
                break
            c=SC.pop(0)
if __name__=='__main__':
    main()

Measured memory_bytes: 3064
using System;
using static System.Console;


public class Hello{
    public static void Main(){
        var n = int.Parse(ReadLine());
        var m = 0;
        var count = 0;
        var list = new int[n];
        for(int i=0;i<n;i++){
            list[i] = int.Parse(ReadLine());
        }
        Array.Sort(list);
        for(int i=0;i<n;i++){
            if(m < list[i]){
                m = list[i];
                count++;
            }
        }
        WriteLine(count);
    }
}


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

int main(void){
    int N;
    cin>>N;
    if(N==3){
        cout<<"2 5 63"<<endl;
        return 0;
    }

    vector<int> res;
    rep(i,30000/12){
        for(int j : {2,4,3,9,8,10,6,12}){
            res.push_back(i*12 + j);
        }
    }

    if(N&1) res[N-1] = 30000;
    rep(i,N){
        cout<<res[i]<<(i==N-1 ? "\n" : " ");
    }
    return 0;
}


Measured memory_bytes: 512
using System;

namespace abc055
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            long p = 1;

            long mod= Convert.ToInt64(Math.Pow(Convert.ToDouble(10), Convert.ToDouble(9)) + Convert.ToDouble(7));
            
            for (int i = 1; i <= n; i++)
            {
                p = p * Convert.ToInt64(i);
                p = p % mod;               
            }

            Console.WriteLine(p.ToString());
        }
    }
}


Measured memory_bytes: 11348
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#define R(i, n) for(int i = 0;i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define SAL(i, n, a) R(i, n) scanf("%lld", a + i)
#define SC(a) scanf("%c", &a);
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("Yes");
#define PN printf("No");
#define Py printf("yes");
#define Pn printf("no");
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;

ll N;

int main() {
	SL(N);
	int sq = 1;
	int i = 2;
	while ((ll)i * i <= N) {
		if (N % i == 0) sq = i;
		i++;
	}
	int sq2 = N / sq;
	string a = to_string(sq), b = to_string(sq2);
	if (a.length() > b.length()) P(a.length());
	else P(b.length());
}

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

int main(){
  int n,m;
  cin >> n >> m;
  bool res=false;
  if(n%2){//odd
    if( (n/2+1)>=m)
      res = true;
  }else{//even
    if(n/2>=m)
      res=true;
  }
  if(res)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
num_list = list(map(int,input().split()))

cnt=0
for i in range(1,N-1):
  temp_list = num_list[i-1:i+2]
  sort_list = sorted(temp_list)
  if temp_list[1] == sort_list[1]:
    cnt+=1
print(cnt)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int x,y,z;
  cin >> x >> y >> z;
  
  x -= z;
  
  cout << x /(y+z) << endl;

 return 0;
}

Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    XY=LLIN(N)

    X=[]
    Y=[]
    for x,y in XY:
        X.append(x-y)
        Y.append(x+y)
    
    X.sort()
    Y.sort()

    ans = max(X[-1]-X[0], Y[-1]-Y[0])
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 63828
N = int(input())
s = [''] * N
for _ in range(N):
    tmp = sorted(input())
    s[_] = ''.join(tmp)
tmp = sorted(s)
cnt = 1
index = 0
ansFlag = True
ans1 = 0
while ansFlag:
    cnt = 1
    for j in range(index + 1, N):
        if tmp[index] == tmp[j]:
            cnt += 1
            index += 1
        else:
            index += 1
            break

    tmp2 = 0
    for i in range(cnt, 0, -1):
        tmp1 = i - 1
        tmp2 += tmp1
        ans = tmp2
    ans1 += ans
    if index == (N - 1):
        ansFlag = False

print(ans1)


Measured memory_bytes: 11368
#include <algorithm>
#include <iostream>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

// int gcd(int a, int b) {
ll gcd(ll a, ll b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

int main() {
    ll a, b;
    cin >> a >> b;
    printf("%lld\n", a * b / gcd(a, b));

    return 0;
}


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

#define INF (1 << 29)
#define rep2(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) rep2(i,0,n)
#define EPS 1e-10

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

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

int n,a,b;
int ca = 0, cb = 0;

bool func(char c){
    if(c=='c') return false;
    if(c=='a' && ca+cb < a + b){
        ca++;
        return true;
    }
    if(c=='b' && ca+cb < a+b && cb < b){
        cb++;
        return true;
    }
    return false;
}

int main()
{
    cin >> n >> a >> b;
    string str;
    cin >> str;

    rep(i,str.size()) if(func(str[i])){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 896
from collections import Counter
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


N,M=[int(i) for i in input().split(" ")]
uf = UnionFind(N)
for _ in range(M):
    A,B=[int(i) for i in input().split(" ")]
    uf.union(A-1,B-1)

c=Counter([uf.find(i) for i in range(N)])
print(len(c)-1)


Measured memory_bytes: 17052
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): return k.join(list(map(str, lst)))
INF = float('inf')

def solve():
    n = II()
    A = LI()
    A = sorted(A)
    # print(A)
    # for _ in range(10):
    while 1:
        if len(set(A)) == 1:
            print(A[0])
            return

        a0 = A[0]
        for i in range(1, n):
            ai = A[i]
            if ai % a0 == 0:
                A[i] = a0
            else:
                A[i] = ai % a0
        A = sorted(A)
        # print(A)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 15120
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;

	vector<pair<int, int>> sushi(N);
	for (int i = 0; i < N; i++)
	{
		cin >> sushi[i].first >> sushi[i].second;
	}

	sort(sushi.begin(), sushi.end(),
		[](const pair<int, int> a, const pair<int, int> b) {
		if (a.second == b.second) return a.first > b.first;
		return a.second > b.second;
	});

	vector<bool> flag(N + 1, false);
	stack<pair<int, int>> check;
	long long good = 0, x = 0;
	for (int i = 0; i < K; i++)
	{
		good += sushi[i].second;
		if (flag[sushi[i].first]) {
			check.push(sushi[i]);
		}
		else {
			flag[sushi[i].first] = true;
			x++;
		}
	}

	long long ans = good + x * x;
	for (int i = K; i < N; i++) {
		if (!flag[sushi[i].first]) {
			if (!check.empty()) {
				flag[sushi[i].first] = true;
				good += sushi[i].second - check.top().second;
				x++;
				check.pop();
				ans = max(ans, good + x * x);
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
string s;
int n;
char reverse(char a){
	if(a == 'W')return 'S';
	else return 'W';
}
string dfs(string ans,int index){
	if(index == n+2){
		return ans;
	}

	return dfs(ans,index+1);
}

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

	cin >> n;
	cin >> s;
	s+=s[0];
	//0 = hitsuji,1 = ookami
	string tmps = "SS";
	REP(i,4){
		if(i == 2)tmps[0] = 'W';
		if(i == 1)tmps[1] = 'W';
		if(i == 3)tmps[1] = 'S';
		string ans = tmps;
		for(int index = 0;index <n;index++){
			if(ans[index+1] == 'S'){
				if(s[index+1] == 'o')
					ans += ans[index];
				else ans += reverse(ans[index]);
			}else{
				if(s[index+1] == 'o')
					ans += reverse(ans[index]);
				else ans += ans[index];
			}
		}
		if(ans[0] == ans[n] && ans[1] == ans[n+1]){

			cout << ans.substr(0,n) << endl;
			return 0;
		}
	}
	cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 812
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  string a, b, c;
  cin >> a >> b >> c;
  
  cout << a[0] << b[1] << c[2] << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <string>
#include <bitset>
#include <algorithm>
#include <functional>
#include <limits.h>
using namespace std;
using ll = long long;

int main(){
    ll ans=0;
    ll m=LONG_MAX;
    ll N,cnt=0;
    cin >> N;
    for(ll i=0;i<N;i++){
        ll a;
        cin >> a;
        if (a<0) cnt++;
        ans+=abs(a);
        m = min(m,abs(a));
    }

    if (cnt%2==1) ans-=2*m;
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
total = sum(a)
b = 0
arr = []
ans = 0
for i in range(n - 1):
  b += a[i]
  c = total - b
  arr.append(abs(b - c))
  if abs(b - c) == 0:
    break
ans = min(arr)
print(ans)

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

using namespace std;

int main(){
	string s[3];
	cin >> s[0] >> s[1]>> s[2];
	int p[3] = {}, q = 0;
	while(1){
		if(p[q] == s[q].size()){
			break;
		}
		p[q]++;
		q = s[q][p[q] - 1] - 'a';
	}
	cout << (char)('A' + q) << endl;
}

Measured memory_bytes: 256
n,k=[int(x) for x in input().split()]
p=[int(x)-1 for x in input().split()]
c=[int(x) for x in input().split()]

ans=max(c)
if ans<0:
    print(ans)
    exit()

for i in range(n):
    #最後に自分という順番
    nxt=i
    lp=[]
    while 1:
        nxt=p[nxt]
        lp.append(nxt)
        if nxt==i:
            break
    lpc=sum(c[x] for x in lp)
    nxt=i
    lpl=len(lp)
    wks=0
    for j in range(lpl):
        nxt=p[nxt]
        wks+=c[nxt]
        ans=max(ans,(k-j-1)//lpl*max(0,lpc)+wks)
        if j==k-1:
            break
print(ans)


Measured memory_bytes: 81712
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

long long gcd(long long a,long long b){
	long long x=max(a,b),y=min(a,b);
	if(x%y==0)return y;
	else return gcd(y,x%y);
}

int main(){
	
	long long a,b;
	cin >> a >> b;
	
	long long ma=max(a,b);
	long long mi=min(a,b);
	long long g=gcd(mi,ma);
	
	map<long long , long long> mp;
	mp[1]=1;
	
	long long base=g;
	for(long long i=2;i*i<=base;i++){
		if(g%i==0){
			mp[i]=1;
			while(1){
				if(g%i!=0)break;
				g/=i;
			}
		}
	}
	mp[g]=1;
	long long ans=0;
	for(auto p : mp){
		ans++;
	}
	cout << endl;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <math.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; }

const long long INF = 1LL << 60;

int main(){
    long long n;
    cin >> n;

    long long a[100010];
    long long b[100010];
    long long c[100010];
    long long dpa[100010];
    long long dpb[100010];
    long long dpc[100010];

    for(int i = 0; i < 100010; ++i) 
    {
        dpa[i] = 0;
        dpb[i] = 0;
        dpc[i] = 0;
    }

    for(int i = 0; i < n; ++i) cin >> a[i] >> b[i] >> c[i];

    for(int i = 0; i < n; ++i)
    {
        chmax(dpa[i + 1], dpb[i] + a[i]);
        chmax(dpa[i + 1], dpc[i] + a[i]);

        chmax(dpb[i + 1], dpa[i] + b[i]);
        chmax(dpb[i + 1], dpc[i] + b[i]);

        chmax(dpc[i + 1], dpb[i] + c[i]);
        chmax(dpc[i + 1], dpa[i] + c[i]);
    }
    
    long long max;
    long long x = dpa[n];
    long long y = dpb[n];
    long long z = dpc[n];

    if(x > y)
    {
        max = x > z ? x : z;
    }
    else
    {
        max = y > z ? y : z;
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main()
{
 long long int n,seisu,goukei;
  int i;
 long long int max,min;

  cin >> n;
 
 cin >> seisu;

 max = seisu;
 min = seisu;
 goukei = seisu;

  for(i = 0;i < n-1;i++){

    cin >> seisu;

   

    if(max <= seisu){

      max = seisu;

    }

    if(min >= seisu){

      min = seisu;

    }

    goukei = goukei + seisu;

  }

  cout << min << " " << max << " " << goukei << "\n";
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b, c;
	cin >> a >> b >> c;
	if(a>b*c){
		cout << "No";
	}else{
		cout << "Yes";
	}
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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 dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    char a; cin >> a;
    if (a >= 'A' && a <= 'Z') {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }
    return 0;
}

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

typedef long long ll;

int main()
{
    int n,tmp;
    int i,j;
    cin >> n;
    int maxv = -1e9-1;
    int minv;
    cin >> minv;
    for(i = 1;i < n;++i){
        cin >> tmp;
        maxv = max(maxv,tmp-minv);
        minv = min(minv,tmp);
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3116