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

typedef long long ll;

int a, b, c;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b >> c;
    int v1 = abs(a - b) + abs(a - c);
    int v2 = abs(b - a) + abs(b - c);
    int v3 = abs(c - b) + abs(a - c);
    cout << min(min(v1, v2), v3) << endl;

    return 0;
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int main(){
    int n; cin>>n;
    int arr[n]; for(int i=0;i<n;i++) cin>>arr[i];
    int ans = 1;
    int mini = arr[0];
    for(int i=1;i<n;i++){
        if(arr[i]<mini){
            mini = arr[i];
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
// C++ program to count the Minimum number of 
// increasing subsequences 
#include <bits/stdc++.h> 
using namespace std; 

int MinimumNumIncreasingSubsequences(int arr[], int n) 
{ 
	multiset<int> last; 

	// last element in each increasing subsequence 
	// found so far 
	for (int i = 0; i < n; i++) { 

		// here our current element is arr[i] 
		multiset<int>::iterator it = last.lower_bound(arr[i]); 

		// iterator to the first element larger 
		// than or equal to arr[i] 
		if (it == last.begin()) 

			// if all the elements in last larger 
			// than or to arr[i] then insert it into last 
			last.insert(arr[i]); 

		else { 
			it--; 

			// the largest element smaller than arr[i] is the number 
			// before *it which is it-- 
			last.erase(it); // erase the largest element smaller than arr[i] 
			last.insert(arr[i]); // and replace it with arr[i] 
		} 
	} 
	return last.size(); // our answer is the size of last 
} 

// Driver program 
int main() 
{ 
int n;cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
    	cin>>arr[i];
	cout<< MinimumNumIncreasingSubsequences(arr, n); 
	return 0; 
} 


Measured memory_bytes: 5376
#include<iostream>

using namespace std;

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

	int x, y;
	cin >> x >> y;
	if(y%2) cout << "No";
	else{
		int a = y/2 - x, b = 2*x - y/2;
		if(a>=0 and b>=0) cout << "Yes";
		else cout << "No";
	}
	return 0;
}

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

int main(){
  int a, b, c, d;
  cin >> a  >> b  >> c >> d;
  
  int x = c - a;
  int y = d - b;
  cout << c - y << " " << d + x << " " << a - y << " " << b + x;
}

Measured memory_bytes: 256
s = sorted(list(input()))
t = sorted(list(input()), reverse=True)

s_iter = iter(s)
t_iter = iter(t)

len_s, len_t = len(s), len(t)

for _ in range(min(len_s, len_t)):
    next_s = next(s_iter)
    next_t = next(t_iter)
    if next_s > next_t:
        print('No')
        break
    elif next_s < next_t:
        print('Yes')
        break
else:
    if len_s >= len_t:
        print('No')
    else:
        print('Yes')

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define mod 1000000007
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;
#define MAX 20

inline int add(int a, int b) {a += b; if (a < 0) a += mod; return a;}
inline int sub(int a, int b) {a -= b; if (a < 0) a += mod; return a;}
inline int mul(int a, int b) {return (a * 1ll * b) % mod;}
inline int pwr(int x, ll y) {
    int ans = 1 % mod;
    while (y) {
        if (y & 1) ans = mul(ans, x);
        x = mul(x, x);
        y >>= 1;
    }
    return ans;
}
inline int inv(int a) {return pwr(a, mod - 2);}

string str, ans;
vector <int> vec, cost = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int dgt;
map <string, string> mp;
int req;

void wtf(ll cur) {
    if (cur == 0) {
        if (ans.size() < str.size()) {
            sort(allr(str));
            ans = str;
        }
        else if (ans.size() == str.size()) {
            sort(allr(str));
            ans = max(ans, str);
        }
        return;
    }
    for (int i = 0; i < dgt; i++) {
        if (cur - cost[vec[i]] >= 0) {
            cur -= cost[vec[i]];
            str.insert((int)str.size(), 1, vec[i] + 48);
            wtf(cur);
            cur += cost[vec[i]];
            str.pop_back();
        }
    }
}

string cmpr(string str1, string str2) {
    if (str1.size() > str2.size()) {
        return str1;
    }
    else if (str1.size() < str2.size()) {
        return str2;
    }
    else {
        return max(str1, str2);
    }
}

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

    int a, b;
    cin >> a >> b;
    cout << (b % a? b - a: a + b) << endl;

    return 0;
}


Measured memory_bytes: 256
# osa9さんの解答を写経 → parの数値周りをわかりやすいように変更
# 解法：最も人数の多い友達集合の要素数分のグループに分ければ良い
# (1,3),(1,5),(2,4)は(1,3,5),(2,4)と等しい(友達の友達は友達)
# なので1,3,5の3人を別々のグループにするために最低3つのグループが必要という解になる

# Counterはリストの要素の出現個数をカウントするメソッド
from collections import Counter

n, m = map(int,input().split())

# 人数情報と任意の一人を引数にその一人の友達が誰かを辿る関数
def parent(par, i):
    depth = 1
    while par[i-1]!=i:  # 
        i = par[i-1]
        depth += 1
    return i, depth

# 人数の情報(par)と友達関係の情報を引数にparを友達集合に変換する
def union(par, a, b):
    pa, da = parent(par, a)
    pb, db = parent(par, b)
    if da < db:
        par[pa-1] = par[pb-1]
    else:
        par[pb-1] = par[pa-1]

# par_org=[0,1,2,3,4]
par = [i for i in range(1,n+1)]

# Tips：for文カウンタをfor文無いで使用しない時はアンダーバーを使用
for _ in range(m):
    a,b = map(int,input().split())
    union(par, a, b)

c = Counter()
for i in range(n):
    c.update([parent(par,i)[0]])

# 出現回数順に要素を取得するmost_commonメソッド
# most_commonの引数には返り値の要素数(デフォは全部)
# 返り値はタプル型で("要素","出現回数")の形で返ってくるため、most_common(1)[0]で最頻出のタプル
# 後ろの[1]で返り値タプルの"出現回数"の値を表示させている
print(c.most_common(1)[0][1])

Measured memory_bytes: 98028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            
            int a = int.Parse(str[0]);
            int i = 2;
            while (true)
            {
                if (a <= i)
                {
                    Console.WriteLine(a);
                    break;
                }
                if (a % i == 0)
                {
                    a++;
                    i = 1;
                }
                i++;
                
            }
        }
    }
}

Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String[] args){
		ArrayList<Integer>	list 	= new ArrayList<Integer>();
		String[] lineStr = null;
		StringBuilder sb = new StringBuilder();
		String s;
		BufferedReader br;
		br = new BufferedReader(new InputStreamReader(System.in));
		try {
			lineStr = br.readLine().split(" ");
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		for(int i=0; i<lineStr.length; i++){
			list.add(Integer.parseInt(lineStr[i]));
		}
		
		Collections.sort(list);
		Collections.reverse(list);
		
		for(int i=0; i<list.size(); i++){
			sb.append(list.get(i) + " ");
		}
		s = sb.toString();
		System.out.println(s.trim());
		
		
	}
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  string s; cin >> s;
  vector<int> freqs(30, 0);
  for (int i = 0; i < (int)s.size(); ++i) {
    ++freqs[s[i] - 'a'];
  }
  bool ok = true;
  for (int i = 0; ok and i < 30; ++i) {
    if (freqs[i] > 1) { ok = false; }
  }
  printf("%s\n", ok ? "yes" : "no");
  return 0;
}


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

namespace AtCorder
{
    public static class Program
    {
        static public void Main(string[] args)
        {
            int output = 0;
            int[] input1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if (input1[0] < 10)
            {
                output = input1[1] + (100 * (10 - input1[0]));
            }
            else
            {
                output = input1[1];
            }

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




Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define maxn 100010
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 998244353
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
int a[maxn], n;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += a[i] / 2;
		a[i] %= 2;
		if (a[i + 1] && a[i])
			a[i]--, a[i + 1]--, ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e+9
#define MOD (int)1e9+7
#define debug(x) cerr << #x << ": " << x << "\n";
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void){
    int M; cin >> M;
    cout << 48 - M << '\n';
    return 0;
}

Measured memory_bytes: 256
K=int(input())
queue=[1,2,3,4,5,6,7,8,9]
i=0
flag=1
while(flag==1):
  if K<=len(queue):
    flag=0
    break
  else:

    x=queue[i]
    if x % 10!=0:
      queue.append(x*10+(x%10)-1)
    queue.append(10*x+(x%10))

    if x%10!=9:
      queue.append(10*x+(x%10)+1)
    
  
  i+=1



print(queue[K-1])



Measured memory_bytes: 7196
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;
ll common_multiple(ll a, ll b) {
	ll  r, x, tmp;
	x = a * b;

	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return x / b;
}


int main() {
	ll a, b, c, d,x,y;
	cin >> a >> b >> c >> d;
	a--;
	x = (b - (b / c) - (b / d) + (b / common_multiple(c,d)));
	y = (a - (a / c) - (a / d) + (a / common_multiple(c,d)));
	cout << x-y << endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define Int int64_t
using namespace std;

int N,Q;

int main()
{
    cin>>N;
    vector<int64_t> A(N);
    unordered_map<Int,Int> mp;
    for(auto &x:A) cin>>x,mp[x]++;
    
    int64_t sum=accumulate(A.begin(),A.end(),0LL);
    
    cin>>Q;
    while(Q--){
        int a,b;
        cin>>a>>b;
        sum-=a*mp[a];
        sum+=b*mp[a];
        mp[b]+=mp[a];
        mp[a]=0;
        cout<<sum<<"\n";
    }
}

Measured memory_bytes: 7736
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Harmony
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b;
  scanf("%d%d", &a, &b);

  int ab = a + b;
  if (ab & 1) puts("IMPOSSIBLE");
  else printf("%d\n", ab / 2);
  return 0;
}


Measured memory_bytes: 256
import sys
n=int(input())
s=input()
MOD=10**9+7
if s[0]=='W' or s[-1]=='W':
  print(0)
  sys.exit()
a=[-1]*(2*n)
current=1
for i in range(2*n-1):
  a[i]=current
  if s[i]==s[i+1]:
    current=1-current
if current==1:
  print(0)
  sys.exit()
a[2*n-1]=0
if sum(a)!=n:
  print(0)
  sys.exit()
ans=1
current=0
for i in range(2*n):
  if a[i]==1:
    current+=1
  else:
    current-=1
  if current<0:
    print(0)
    sys.exit()
current=0
for i in range(2*n):
  if a[2*n-1-i]==0:
    current+=1
  else:
    current-=1
  if current<0:
    print(0)
    sys.exit()
current=0
for i in range(2*n):
  if a[2*n-1-i]==0:
    current+=1
  else:
    ans=(ans*current)%MOD
    current-=1
for i in range(1,n+1):
  ans=(ans*i)%MOD
print(ans)


Measured memory_bytes: 42720
read = input
# read = Read(False, """


# 8 1000 800 100
# 300
# 333
# 400
# 444
# 500
# 555
# 600
# 666

# """).read
tmp = read()
tmp = list(map(int, tmp.split(' ')))
N,A,B,C = tmp
opt = list(map(int, map(lambda x: read(), range(N))))
def dfs(n,a,b,c):
    ret = 10**7
    if(n == N):
        if(min(a,b,c) == 0):
            return ret
        return abs(A - a) + abs(B - b) + abs(C - c) - 30
    cur = opt[n]
    ret = min(ret, dfs(n+1, a + cur, b, c) + 10)
    ret = min(ret, dfs(n+1, a, b + cur, c) + 10)
    ret = min(ret, dfs(n+1, a, b ,c + cur) + 10)
    ret = min(ret, dfs(n+1, a, b ,c ) + 0)
    return ret
print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
import sys
def input(): return sys.stdin.readline().strip()

def main():
    N = int(input())
    K = int(input())
    X = list(map(int, input().split()))
    ans = 0
    for i, x in enumerate(X):
        ans += min(abs(x), abs(x - K))
    print(ans * 2)
    


if __name__ == "__main__":
    main()


Measured memory_bytes: 61864
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let a = get!([usize]);
    let mut vec = vec![0; 100_001];

    for e in a {
        vec[e] += 1;
    }
    let nums = vec.into_iter().filter(|&e| e > 0).collect::<Vec<_>>();

    let mut sum = 0usize;
    let even_num = nums.iter().filter(|&e| e % 2 == 0).count();
    if even_num == 2 {
        let idx = nums.iter().position(|&e| e % 2 == 0).unwrap();
        if nums[idx+1] % 2 == 0 {
            sum += 4;
        } else {
            sum += 2;
        }
    } else if even_num % 2 == 0 {
        sum += even_num;
    } else {
        sum += even_num + 1;
    }

    sum += nums.into_iter().map(|e| if e % 2 == 0 { e - 2 } else { e - 1 }).sum::<usize>();
    println!("{}", n - sum);
}


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

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> a(H);
  for(int i=0;i<H;i++){cin >> a[i];}
  for(int i=0;i<W+2;i++){cout << '#';}
  cout << endl;
  for(int i=0;i<H;i++){
    cout << '#' << a[i] << '#' << endl;
  }
  for(int i=0;i<W+2;i++){cout << '#';}
  cout << endl;
}

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

using namespace std;

int N, A[100000];
vector<int> es;

int main(){
	cin >> N;
	for(int i = 0; i < N; ++i) cin >> A[i];
	sort(A, A + N);
	
	for(int i = 0; i < N - 1; ++i){
		if(A[i] == A[i+1]){
			es.push_back(A[i]);
			++i;
		}
	}
	
	if(es.size() >= 2){
		cout << 1LL*es[es.size()-2]*es[es.size()-1] << endl;
	}else{
		cout << 0 << endl;
	}
}

Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		int n=sc.nextInt();
		sc.nextLine();
		for(int i=0; i<n; i++){
			String s=sc.nextLine();
			s=s.replaceAll("Hoshino", "Hoshina");
			println(s);
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if( (A==B && C!=A) || (B==C && A!=B) || (C==A && B!=C))
    cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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


int main(){
    int N;
    cin>>N;
    vector<vector<int> > V(N, vector<int>(3)), dp(N, vector<int>(3,0));
    for(int i=0;i<N;i++)
        cin>>V[i][0]>>V[i][1]>>V[i][2];
    for(int i=0;i<N;i++)
        if(i==0)
            dp[i]=V[i];
        else
            for(int j=0;j<3;j++)
                dp[i][j]=V[i][j]+max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]);    
    cout<<max(max(dp[N-1][0], dp[N-1][1]), dp[N-1][2])<<endl;
    return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ll long long
#define int long long
#define mod 1000000007
#define DEBUG cout<<"Hello1\n";
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))
#define deb(...) debug(#__VA_ARGS__, __VA_ARGS__);
const int N = 1e6 + 5;
const double pi =  acosl(-1);
const ll inf = 1e18 + 5;
using namespace std;
template<typename T> void debug(string s, T x) {cout << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cout << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}
template<class T> void print_container(T &container) { for (auto &t : container) { cout << t << " ";} cout << endl;}
template<class T> void printArr(T &a , int n) { for (int i = 0; i < n; i++) {cout << a[i] << " ";} cout << endl;}

//Template Ends
int n;

void solve() {
	cin >> n;

	cout << n*n*n + n*n + n << endl;
}

int32_t main() {
	IOS;

	solve();

	return 0;
}




Measured memory_bytes: 3532
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n):
  if a[i]<0:
    c+=1
    a[i]=a[i]*-1
if c%2==0 or 0 in a:
  print(sum(a))
else:
  a.sort()
  print(sum(a[1:])-a[0])

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

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  
  int answer = 0;
  if (a!=b) {
    answer ++;
  }
  if (a!=c) {
    answer ++;
  }
  if (b!=c) {
    answer ++;
  }
  if (a==b&&b==c) {
    answer ++;
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i=0,j;
  char str[8];
  
  fgets(str,sizeof(str),stdin);  

  if(str[0] == str[2])
  {
    puts("Yes");
  }else
  {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 128
import math


def nCm(n, m):
    return math.factorial(n) / (math.factorial(m) * (math.factorial(n - m)))


N, P = map(int, input().split())
A = map(int, input().split())
A = list(map(lambda X: X % 2, A))
OddNumber = A.count(1)
EvenNumber = len(A) - OddNumber
AllNumber = 2 ** len(A)

i = 2
OddCount = 0
while OddNumber >= i:
    OddCount += nCm(OddNumber, i)
    i += 2
ans = (1 + OddCount) * (2 ** EvenNumber)
if P == 0:
    print(int(ans))
else:
    ans = AllNumber - int(ans)
    print(int(ans))

Measured memory_bytes: 3064
n = int(input()) 
a = list(map(int,input().strip().split()))[:n]
pro=1
f=1
a.sort()
for i in a:
  pro=pro*i
  if(pro>1000000000000000000):
    f=0
    print(-1)
    break
if(f==1):
  print(pro)

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    sort(all(a),greater<ll>());
    ll sum = a[0];
    int locate = 1;
    int pnt = 0;
    rep(i,2,n) {
        if( pnt < 2 ){
            sum += a[locate];    
            pnt++;   
        }else {
            locate++;
            sum += a[locate];
            pnt=1;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    string s;
    cin>>s;
    int k;cin>>k;
    set<string> x;
    int n=s.size();
    rep(i,n){
        x.insert(s.substr(i,1));
    }
    rep(i,n-1){
        x.insert(s.substr(i,2));
    }
    rep(i,n-2){
        x.insert(s.substr(i,3));
    }
    rep(i,n-3){
        x.insert(s.substr(i,4));
    }
    rep(i,n-4){
        x.insert(s.substr(i,5));
    }
    auto it=x.begin();
    advance(it,k-1);
    cout<<*it<<endl;
}


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

typedef long long ll;

/*
const ll M = 1000000007;
vector<ll> fac(3001);
vector<ll> ifac(3001);
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
*/


ll lcm(ll a,ll b){
 
  ll r, x, tmp;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

ll gcd(ll a ,ll b){
    if(a==0){return b;}
    else if(b==0){return a;}
    else{
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
    }
}

bool sosu(ll p){
    bool ans = true;
    double psqrtd = pow(p, 0.5);
    ll psqrt = psqrtd;
    for(ll i = 2; i <= psqrt; i++){
        if(p%i==0)ans = false;
    }
    if(p==1)ans = false;
    return ans;
}



int main(void){
    ll n,m;
    cin >> n;
    double ans;
    if(n%2==0)cout << 0.50000000 << endl;
    else {m = n/2 + 1;ans = (m*1.0)/(n*1.0);cout << ans << endl;}
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
ans = []
for i in range(2**n):
    cnt = 0
    for j in range(n):
        if i>>j&1 ==1:
            cnt += 1
    if cnt == k:
        st = []
        for t in range(n):
            if i>>t&1 ==1:
                st.append(t)
        print("{}:".format(i),end =" ")
        print(*st)




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

int main() {
  int N; // [1, 100]
  cin >> N;

  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }

  sort(a.begin(), a.end(), greater<int>());
  int s = 0;
  for(int i=0;i<N;i++){
    if(i%2 == 0){
      // Alice
      s += a.at(i);
    }else{
      s -= a.at(i);
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define int long long
il int read()
{
	int k=1,re=0;char ch=getchar();
	while(ch>'9'||ch<'0'){ch=getchar();}
	while(ch<='9'&&ch>='0'){re=re*10+ch-48;ch=getchar();}
	return re*k;
}
void write(int x)
{
	if(x<0)return write(-x),void();
	if(x<=9)return putchar(x+48),void();
	return write(x/10),write(x%10),void();
}
string s1,s2;
signed main()
{
	cin>>s1>>s2;
	for(int i=0;i<s1.size();i++)
	{
		if(s1[i]!=s2[i]||s1.size()>s2.size())
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second

vector<string> v;

int main(){
    int k;
    string s;
    cin >> s >> k;
    for(int i=0;i < s.size();i++)
    {
        for(int j=1;j<=5 && j+i-1<s.size();j++)
        {
            v.push_back(s.substr(i,j));
        }
    }//全文字列を生成
    sort(v.begin(),v.end());
    unique(v.begin(),v.end());

    cout << v.at(k-1) << endl;
}

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

int main()
{
  int N , x , sum ;
  
  cin >> N ;
  
  sum = 0 ;
  x = N ;
  
  while(x != 0)
  {
    sum += x%10 ;
    x /= 10 ;
  }
  
  if(N%sum == 0)
    cout << "Yes" << endl ;
  else
    cout << "No" << endl ;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
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 N, M;
vector<vector<int>> G;

int dp[101010];
int rec(int v) {
  if(dp[v] != -1) return dp[v];
  int res = 0;
  for(auto nv : G[v]) chmax(res, rec(nv) + 1);
  return dp[v] = res;
}

int main() {
  cin >> N >> M;
  G.assign(N, vector<int>());
  rep(i, 0, M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
  }
  rep(i, 0, N) dp[i] = -1;
  int res = 0;
  rep(i, 0, N) chmax(res, rec(i));
  cout << res << endl;
  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int sum;
  for (int i = 0; i < N; i++) {
  	int x;
    cin >> x;
    if (x < K -x) {
      sum = sum + 2 * x;
    } else {
      sum = sum + 2 * (K - x);
    }
  }
  cout << sum << endl;
}

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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    unordered_map<int, int> mp;
    for(int i = 0; i < N; i++){
        int a; cin >> a;
        mp[a%4]++;
    }
    if(2 * mp[0] +1 == N && N % 2 == 1){
        cout << "Yes\n";
        return 0;
    }
    if(2 * mp[0] + mp[2] >= N) cout << "Yes\n";
    else cout << "No\n";


}

Measured memory_bytes: 640
import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in R(V)]
    FromStdin=True if ls==None else False
    for i in R(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
    #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in R(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

ans=0

n=I()
a=[0]*(n+1)

#for i in range(l,r+1):
for x in rep(1,101):
    for y in rep(1,101):
        for z in rep(1,101):
            t=x**2+y**2+z**2+x*y+y*z+z*x
            if t<=n:
                a[t]+=1

for i in rep(n):
    print(a[i+1])




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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

typedef long long int ll;
typedef long int li;

const ll mod = 1000000007;
const ll inf = 1000000000000000000;

typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vli> vvli;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef map<ll, ll> mll;
typedef map<ll, string> mls;
typedef map<string, ll> msl;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#pragma GCC optimize ("-O3")
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
#define PI 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define tol(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define tou(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define all(v) v.begin(), v.end()
#define FOR(i, j, k, in) for(li i=j; i<k; i+=in)
#define RFOR(i, j, k, de) for(li i=j; i>=k; i-=de)
#define rep(i,j,k) FOR(i, j, k, 1)
#define rrep(i,j,k) RFOR(i, j, k, 1)
#define repc(v) for(auto it=v.begin(); it!=v.end(); it++)
#define T ll t; cin>>t; while(t--)

ll gen(){
    ll temp;
    cin>>temp;
    return temp;
}

int main(){
  FAST

  int s,w;
  cin>>s>>w;
  if(w>=s)
    cout<<"unsafe";
  else cout<<"safe";
  
  return 0;
}







Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

struct val {
    ll a;
    ll b;
    ll c;
    ll d;
};
ll recursive(vector<ll> &A, ll i, ll M, vector<val> &vs) {
    if (i == A.size() - 1) {
        ll total = 0;
        for (auto v : vs) {
            if (A[v.b] - A[v.a] == v.c) {
                total += v.d;
            }
        }
        return total;
    }
    ll maxscore = 0;
    for (ll j = A[i]; j <= M; j++) {
        A[i + 1] = j;
        maxscore = max(maxscore, recursive(A, i + 1, M, vs));
    }
    return maxscore;
}

int main() {
    ll N, M, Q;
    cin >> N >> M >> Q;
    vector<val> vs(Q);
    for (ll i = 0; i < Q; i++) {
        val v;
        cin >> v.a >> v.b >> v.c >> v.d;
        v.a--;
        v.b--;
        vs[i] = v;
    }

    vector<ll> A(N);
    ll maxval = 0;
    for (ll j = 1; j <= M; j++) {
        A[0] = j;
        maxval = max(maxval, recursive(A, 0, M, vs));
    }
    print(maxval);
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <math.h>
int main()
{   
int K,X,Y,i,j,z;
scanf("%d %d %d",&K,&X,&Y);
int A[K];
int saX,saY,Arute;
for(i=0;i<K;i++){
    A[i]=0;
}
for(i=1;i<K;i++){
    saX=i-X;
    if(i-X<0){
       saX=X-i;
    }
for(j=i+1;j<=K;j++){
    saY=j-Y;
if(j-Y<0){
     saY=Y-j;
    }
     Arute=saX+saY+1;
    if(Arute<j-i){
    A[Arute]=A[Arute]+1;
}
else{A[j-i]=A[j-i]+1;}
}

}
for(z=1;z<K;z++){
    printf("%d\n",A[z]);
}
    return 0;
}

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

using namespace std;

const int max_n = 20, mod = 1000000007;
const int max_e = 199;

const int max_mask = (1 << 19) + 5;

int c[max_e][max_e], pr[max_e][max_e];
int n, m, can_add[max_mask], parent[max_n];
int dp[max_mask];
int cnt[max_mask];
int from[max_e], to[max_e];
vector<int> g[max_n];

int mul(int x, int y) {
    return 1LL * x * y % mod;
}

void get_all_c() {
    for (int i = 1; i < max_e; ++i) {
        pr[i][i - 1] = 1;
        for (int j = i; j < max_e; ++j) {
            pr[i][j] = mul(pr[i][j - 1], j);
        }
    }
    for (int i = 0; i < max_e; ++i) {
        c[i][0] = 1;
        for (int j = 1; j <= i; ++j) {
            c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
        }
    }
}

bool get_bit(int mask, int pos) {
    return (bool) (mask & (1 << pos));
}

int find_set(int v) {
    if (v == parent[v]) {
        return v;
    }
    return parent[v] = find_set(parent[v]);
}

void union_set(int v1, int v2) {
    v1 = find_set(v1);
    v2 = find_set(v2);
    parent[v1] = v2;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    get_all_c();
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> from[i] >> to[i];
        --from[i];
        --to[i];
    }
    int e = n - 1;
    for (int mask = 0; mask < (1 << e); ++mask) {
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
        for (int j = 0; j < e; ++j) {
            if (get_bit(mask, j)) {
                union_set(from[j], to[j]);
            }
        }
        for (int j = e; j < m; ++j) {
            if (find_set(from[j]) == find_set(to[j])) {
                ++can_add[mask];
            }
        }
    }
    dp[(1 << e) - 1] = 0;
    cnt[(1 << e) - 1] = 1;
    for (int mask = (1 << e) - 1; mask; --mask) {
        //cout << mask << ": " << dp[mask] << " " << cnt[mask] << endl;
        int bits = e - __builtin_popcount(mask);
        for (int last = 0; last < e; ++last) {
            if (get_bit(mask, last)) {
                const int to = mask ^ (1 << last);
                int ce = can_add[mask] - can_add[to];
                int cur_e = m - e - can_add[mask] + bits;

                const int C = mul(cnt[mask], pr[cur_e + 1][cur_e + ce]);
                cnt[to] += C;
                cnt[to] %= mod;

                int add = mul(dp[mask], pr[cur_e + 2][cur_e + 1 + ce]);
                add = (add + mul(C, bits + 1)) % mod;
                //cout << "$" << mask << " " << last << ": " << cur_e << " " << ce << ", add = " << add << endl;
                dp[to] += add;
                dp[to] %= mod;
            }
        }
    }
    int ans = dp[0];
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
#define Me3za() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL))
#define endl "\n"
int n,w;
int value[102];
int we[102];
long long mem[102][100005];
long long solve(int i,int v){
 if(i>n){
  if(v==0)return 0;
    return 1e10;
 }
 if(!v)return 0;
 if(~mem[i][v])return mem[i][v];
 long long ch1=solve(i+1,v);
 long long ch2=1e10;
 if(v-value[i]>=0)ch2=solve(i+1,v-value[i])+we[i];
 return mem[i][v]=min(ch1,ch2);
}
int main() {
Me3za();
cin>>n>>w;
for(int i=0;i<n;i++)cin>>we[i]>>value[i];
memset(mem,-1,sizeof mem);
for(int i=100001;i>=0;i--){
    long long ans=solve(0,i);
    if(ans<=w){
        cout<<i<<endl;
        return 0;
    }
}
//cout<<solve();
}


Measured memory_bytes: 80000
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N, M, X = map(int, input().split())

    v = []
    for _ in range(N):
        l = list(map(int, input().split()))
        v.append(l)

    ans = INF
    for b in range(2**N):
        cost = 0
        r = [0] * M
        for i in range(N):
            if (b >> i) & 1:
                cost += v[i][0]
                for j in range(1, M + 1):
                    r[j - 1] += v[i][j]

        ok = True
        for j in range(M):
            ok &= r[j] >= X
        if ok:
            ans = min(ans, cost)

    if ans == INF:
        ans = -1
    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 74440
// ~/BAU/ACM-ICPC/Teams/Rampage/MMZA
// ~/sudo apt-get verdict Accepted
// practice...
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<pair<int, int>> vp;
typedef vector<vector<pair<int, int>>> vvp;
typedef unsigned long long ull;
typedef long double ld;
const int Mod = 1000000007;
int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
//.\a.exe
int n,k;
scanf("%d %d",&n,&k);
printf("%d\n",n%k?1:0);

    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
string S;
	cin >> S;
	ll ans = 0;
	int val = 0;
	fx(S.size()) {
		ll y = x;
		while (x+1<S.size()&&S[x+1]==S[x]) {
			x++;
		}

		if (S[x]=='<') {
			ans += (x - y+1) * (x - y + 2) / 2;
			val = x - y+1;
		}
		else {
			if (x - y>=val) {
				ans += (x - y) * (x - y + 1) / 2;
				ans += x - y + 1 - val;
			}
			else {
				ans += (x - y) * (x - y + 1) / 2;
			}
			val = 0;
		}
		//ce(ans)
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 900
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
d = defaultdict(int)
for i in range(n):
    s = list(input())
    s.sort()
    tmp = ''.join(s)
    d[tmp] += 1
res = 0
for key in list(d):
    v = d[key]
    res += v*(v-1)//2
print(res)

Measured memory_bytes: 19984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> res(4);
  for(int i = 0;i < 4;i++)res[i] = 0;
  for(int i = 0;i < n;i++){
    string s;
    cin >> s;
    if(s[0] == 'A')res[0]++;
    if(s[0] == 'W')res[1]++;
    if(s[0] == 'T')res[2]++;
    if(s[0] == 'R')res[3]++;
  }
  cout << "AC x " << res[0] << endl;
  cout << "WA x " << res[1] << endl;
  cout << "TLE x " << res[2] << endl;
  cout << "RE x " << res[3] << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl


int main(){
	ll n;cin>>n;
	vector<ll> a(n);
	rep(i,n){
	  cin>>a[i];
	}
	ll sum=0,right=0,ans=0;
	rep(i,n){
		while((sum&a[right])==0&&right<n){
			sum+=a[right];
			right++;
		}
		sum-=a[i];
		ans+=right-i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{

			//最初の数値を読み取る。
			String[] strN = insBR.readLine().split(" ");
			int[] intN = new int[strN.length];
			for(int i = 0; i < strN.length; i++){
				intN[i] = Integer.parseInt(strN[i]);
			}

			//ベクトルMNを配列につめる。
			int intGyou = intN[0];
			int intRetsu = intN[1];
			int[][] intMN = new int[intGyou][intRetsu];
			String[][] strMN = new String[intGyou][intRetsu];
			for(int i = 0; i < intGyou; i++){
				strMN[i] = insBR.readLine().split(" ");
			}
			for(int i = 0; i < intGyou; i++){
				for(int j = 0; j < intRetsu; j++){
						intMN[i][j] = Integer.parseInt(strMN[i][j]);
				}
			}

			//M行分の数値を読み取り、配列につめる。
			int[] intM = new int[intRetsu];
			String strLine = "";
			for(int i = 0; i < intM.length; i++){
				strLine = insBR.readLine();
				intM[i] = Integer.parseInt(strLine);
			}

			//ベクトルCを算出する。
			int[] intC = new int[intGyou];
			//int[] intSum = new int[intRetsu];
			for(int i = 0; i < intGyou; i++){
				for(int j = 0; j < intRetsu; j++){
					intC[i] += intMN[i][j] * intM[j];
				}
			}
			for(int i = 0; i < intGyou; i++){
				System.out.println(intC[i]);
			}



		}catch(IOException e){
			System.out.println("入力が無効です。");
		}catch(NumberFormatException e){
			System.out.println("数値を入力してください。");
		}
	}
}



Measured memory_bytes: 27312
#include<stdio.h>

int main(){

   int n=0;            // ????´???°??????????????? n<=10000
   int a=0, b=0;       // A?????????????????°?????¨B?????????????????°??? 0<=a<=9, 0<=b<=9
   int ansA=0, ansB=0; // ????????????A??¨B?????????
   int i;              // ??????????????° i

   scanf("%d", &n);    // ?¬¬1??±?????????????´???°?????????

   while(n!=0){        // ????´???°???0????????°?????????
      ansA = 0;        // ??°????????????????????°????????????
      ansB = 0;

      for(i=0;i<n;i++){
         scanf("%d %d", &a, &b);  // i?????????????????????????????????

         if(a>b){                 // ??§?°???????
            ansA += a + b;        // A???????????§????????????????????????A?????????
         }else if(b>a){
            ansB += a + b;        // B???????????§????????????????????????B?????????
         }else{
            ansA += a;            // ??????????????????????????????????????\???
            ansB += b;
         }
      }

      printf("%d %d\n", ansA, ansB);  // ?????????????????????
      scanf("%d", &n);                // ?¬??????±?????????????´???°?????????
   }

   return 0;

}

Measured memory_bytes: 600