akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



// https://atcoder.jp/contests/abc138/submissions/7013118
// upper_bound ver

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    string s, t;
    cin >> s >> t;
    
    vector<vector<int> > is(26);
    
    int n = sz(s), m = sz(t);
    rep(i, n) is[s[i] - 'a'].eb(i);
    rep(i, n) is[s[i] - 'a'].eb(i + n);
    // 2周する 下のif (p >= n) で便利(場合分けいらない)
    // 2つのforに分けるのは, 昇順にするため
    
    ll ans = 0;
    int p = -1;
    
    // rep(i, sz(is[2])) cout << is[2][i] << " "; cout << endl;
    
    rep(i, m) {
        int c = t[i] - 'a';
        
        if (sz(is[c]) == 0) {
            puts("-1");
            return 0;
        }
        p = *upper_bound(all(is[c]), p);
        // ccc cccとか, 1足さな
        // かつ, 1indexed
        
        // out(p);
        if (p >= n) {
            p -= n;
            ans += n;
        }
    }
    
    ans += p; // 最後の文字
    out(ans + 1);
}


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


int main() {
	int k;
	cin >> k;
	int sum = 0;
	for(int a=1;a<=k;a++) 
		for(int b=1;b<=k;b++) 
			for(int c=1;c<=k;c++) {
				sum+=gcd(gcd(a,b),c);
			}
	cout<<sum<<endl;
	
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a[3];cin>>a[0]>>a[1]>>a[2];
    int num[10]={0,0,0,0,0,0,0,0,0,0};
    for(int i=0;i<3;i++)num[a[i]]++;
    cout<<(num[5]==2&&num[7]==1?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++)

int main() {
int a,b;
cin >> b >>a;
if((b%2)&&(a%2))cout << "Odd";
else cout<< "Even";
return(0);
}


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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
const int mod1 = 998244353;
const int mod2 = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 1e6+5;

spii heap;
int p1[N], p2[N];

void pre(){
  p1[0]=p2[0]=1;
  rep(i,1,N){
    p1[i]=(p1[i-1]*29)%mod1;
    p2[i]=(p2[i-1]*31)%mod2;
  }
}



pii hsh(pii h, int n, int c){
   int x = (h.fi+(c+1)*p1[n])%mod1;
   int y = (h.se+(c+1)*p2[n])%mod2;
   return {x,y};
}

void solve() {

  pre();
  int n, ans = 0;
  cin>>n;
  vector<string> str(n);
  rep(i,0,n)
    cin>>str[i];
  sort(all(str),[](string &s1, string &s2){
    return sz(s1)<sz(s2);
  });
  rep(i,0,n){
     string &s = str[i];
     int m = sz(s);
     vi f(26);
     rep(j,0,m)
       f[s[j]-'a']++;
     pii hs = {0,0};
     frev(j,0,m-1){
        rep(k,0,26){
          if(!f[k])
            continue;
          pii hs1 = hsh(hs,m-1-j,k);
          ans+=heap.count(hs1);
        }
        hs = hsh(hs,m-1-j,s[j]-'a');
        f[s[j]-'a']--;
     }
     heap.insert(hs);
  }
  cout<<ans;

}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
   //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}





/*


int powm(int a, int b, int mod) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}

int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}*/

Measured memory_bytes: 37452
#include<bits/stdc++.h>
using namespace std;
 
#define ll             long long 
#define vi             vector<int>
#define mod            1000000007
#define MAX            INT_MIN
#define MIN            INT_MAX
#define ff             first
#define ss             second
#define pb             push_back
#define bs             binary_search    // binary_search(a,a+n,x);
#define mp             make_pair
#define pii            pair<int,int>
#define pqb            priority_queue<int>
#define lower(x)         transform(x.begin(), x.end(), x.begin(), ::tolower);           
#define upper(x)          transform(x.begin(), x.end(), x.begin(), ::toupper);
#define lb             lower_bound      // lower_bound(a,a+n,x) - a; => For Index
#define up             upper_bound      // upper_bound(a,a+n,x) - a; => For Index       
#define floop(x,n)       for(int i=x;i<n;i++)
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define ps(x,y)        fixed<<setprecision(y)<<x         
#define FIO            ios_base::sync_with_stdio(false); cin.tie(NULL);
                  
void c_p_c()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif   
}    

void solution()
{
    ll int a,b,c,d;
    cin>>a>>b>>c>>d;

    ll int e,f,g,h;

    e = a*c;
    f = a*d;
    g = b*c;
    h = b*d;

    cout<<max(e,max(f,max(g,h)))<<endl;
}

int32_t main()
{
    c_p_c();
    FIO;
 
    // int t;
    // cin>>t;
 
    // while(t--)
    // {
         solution();
    //}
 
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <algorithm>
using namespace std;

using LL = long long;

int main(void)
{
	int num;
	int a[10000];
	scanf("%d", &num);

	for (int i = 0; i < num; i++)
	{
		scanf("%d", &a[i]);
	}

	LL sum = 0;
	int small = a[0];
	int large = a[0];

	for (int i = 0; i < num; i++) {
		sum += (LL)a[i];
		large = max(large, a[i]);
		small = min(small, a[i]);
	}
	printf("%d %d %lld\n", small, large, sum);
	return 0;

}

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

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

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

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

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

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

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

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

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

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

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

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }

    let mut ans = 0;

    let mut ones = vec![0; 60];

    for &ai in &a {
        for i in 0..60 {
            if ai & 1 << i > 0 {
                ones[i] += 1;
            }
        }
    }

    for i in (0..60).rev() {
        // println!("{}, {}", i, ones[i]);
        if ones[i] <= n / 2 && ans | (1 << i) <= k {
            ans |= 1 << i;
        }
    }
    let mut sum = 0;
    // println!("{}", ans);
    for i in 0..n {
        sum += ans ^ a[i];
    }
    println!("{}", sum);
    // println!("{}", a.iter().fold(0, |sum, &x| sum + ans ^ x));
}


Measured memory_bytes: 4352
import java.io.*;
import java.util.Scanner;


public class Main{
    public static void main(String[] args) throws IOException
    {
        Scanner scanner = new Scanner(System.in);
 
        do{
            String line1 = scanner.next();
            String line2 = scanner.next();
            String line3 = scanner.next();

            int a = Integer.parseInt(line1);
            int b = Integer.parseInt(line2);
            int c = Integer.parseInt(line3);

            int sum = (a + b);

            if(a == -1 && b == -1 && c == -1){
                break;
            }

            if(a == -1 || b == -1)System.out.println("F");
            else if(sum >= 80)System.out.println("A");
            else if(sum >= 65)System.out.println("B");
            else if(sum >= 50 || c >= 50)System.out.println("C");
            else if(sum >= 30)System.out.println("D");
            else System.out.println("F");

        }while(true);
       
    }
}




Measured memory_bytes: 26332
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
bool vis[maxn];
int cnt[maxn];
int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    vis[0] = vis[1] = 1;
    for(int i = 2; i * i < maxn; ++i) {
        if(vis[i]) continue;
        for(int j = i * i; j < maxn; j += i) vis[j] = 1;
    }
    for(int i = 2; i < maxn; ++i) {
        if(!vis[i] && !vis[(i + 1) >> 1]) cnt[i]++;
        cnt[i] += cnt[i - 1];
    }
    int n, l, r;
    cin >> n;
    while(n--) {
        cin >> l >> r;
        cout << cnt[r] - cnt[l - 1] << endl;
    }
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
int main(void){
    long long int n,a[10001]={0};
    cin >>n;
    for(int i=0;i<n;i++){
        cin >>a[i];
    }
    long long int min=1000000,max=-1000000,sum=0;
    for(int i=0;i<n;i++){
        if(a[i]<min){
            min=a[i];
        }
        if(a[i]>max){
            max=a[i];
        }
        sum=sum+a[i];
    }
    cout <<min<<" "<<max<<" "<<sum<<endl;
}


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

using namespace std;

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

  int n;
  cin >> n;
  vector<long long> sum(n + 1, 0);
  long long s = 0;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    s += x;
    sum[i] = s;
  }
  sort(sum.begin(), sum.end());

  long long ans = 0;
  for (long long i = 0; i < (long long)sum.size();) {
    long long j = i;
    while (j < sum.size() && sum[i] == sum[j])
      ++j;
    ans += (j - i) * (j - i - 1) / 2;
    i = j;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<int, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}

const int N = 1e5 + 100;

vector<int> G[N];
int val[N];
int cnt[20];
int dp[1 << 20];
int main() {
    int n;
    cin >> n;
    for(int i = 1; i < n; i ++) {
        int u, v, w;
        scanf("%d %d %d", &u, &v, &w);
        u ++, v ++;
        val[u] ^= w;
        val[v] ^= w;
    }

    int ans = n;
    for(int i = 1; i <= n; i ++) cnt[val[i]] ++;

    vector<int> v;
    v.clear();
    for(int i = 0; i <= 15; i ++) {
        if(! i) ans -= cnt[i];
        else {
            ans -= cnt[i] / 2;
            if(cnt[i] % 2) v.push_back(i);
        }
    }

    int sz = SZ(v);
    dp[0] = 0;
    for(int mask = 1; mask < (1 << sz); mask ++) {
        for(int sub = mask; sub; sub = (sub - 1) & mask) {
            int cur = 0;
            for(int i = 0; i < sz; i ++) {
                if((sub >> i) & 1) cur ^= v[i];
            }
            if(cur == 0) dp[mask] = max(dp[mask], dp[mask ^ sub] + 1);
        }
    }
    ans -= dp[(1 << sz) - 1];
    cout << ans << endl;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
ll int power(ll int x, ll int y, ll int p)  
{  
   ll int res = 1;     // Initialize result  
 
    x = x % p; // Update x if it is more than or  
                // equal to p
   
    if (x == 0) return 0; // In case x is divisible by p;
 
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
 
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 


int main()
{
 
  fastio();

ll int T=1;

while(T--)
{
    string s,t;
    cin>>s>>t;

    ll int ans =INT_MAX,i,j;
    int sz1=s.size(),sz2=t.size();
    for(i=0;i<=sz1-sz2;i++)
    {
        ll int tans=0;
        string temp = s.substr(i,t.size());
       // cout<<temp<<endl;
        for(j=0;j<t.size();j++)
        {
            tans+=(t[j]!=temp[j]);
        }
        //cout<<tans<<endl;
        ans=min(ans,tans);
    }
    cout<<ans<<endl;
}



return 0;}

Measured memory_bytes: 3656
package main

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

const mod = 1000000007
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	N, K := sc.i(), sc.i()

	sum := 1
	for i := K; i < N+1; i++ {
		v := (N+1)*N/2 - (N+1-i)*(N-i)/2 - i*(i-1)/2 + 1
		v = v % mod
		sum += v
		sum %= mod
	}
	fmt.Println(sum)

}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 1e5 + 100;

int N;
ll A, B, Nr[MAX_N];
int main() {
	cin >> N >> A >> B; REP(i, N) scanf("%lld", &Nr[i]);
	int ans = 0;
	for(int l=0, r=INF; l<=r; ) {
		int m = (l+r) >> 1;
		ll cnt = 0;
		REP(i, N) {
			ll now = max(0ll, Nr[i] - B * m);
			cnt += (now + (A-B-1)) / (A - B);
		}
		if(cnt <= m) ans = m, r = m-1; else l = m+1;
	}
	printf("%d\n", ans);
	return 0;
}



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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

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

const int N = (int)1e5 + 10;
int nd[N];
bool use[N * 2];
vector<pii> T[N];

bool vis[N];
bool dfs(int u){
  vis[u]=true;
  int cr = 0;
  for(auto x : T[u]){
    if(!vis[x.fi]){
      if(dfs(x.fi)){
        cr ^= 1;
        use[x.se]=true;
      }
    }
  }
  nd[u] ^= cr;
  return nd[u];
}

int main(){
  fastIO;
  int n, m;
  cin >> n >> m;
  vector<pii> cc(n);
  for(int i = 0 ; i < n; i ++ ){
    cin >> cc[i].fi >> cc[i].se;
  }
  cc.push_back(mp((int)1e9 + 10, 0));
  sort(cc.begin(), cc.end());
  int cur = 0;
  for(int i = 0 ; i <= n; i ++ ){
    if(cur != cc[i].se) nd[i]=1;
    else nd[i]=0;
    cur = cc[i].se;
  }
  int l, r;
  int il, ir;
  for(int i = 0 ; i < m ; i ++ ){
    cin >> l >> r;
    il=lower_bound(cc.begin(),cc.end(),mp(l,-1))-cc.begin();
    ir=lower_bound(cc.begin(),cc.end(),mp(r+1,-1))-cc.begin();
    if(il==ir) continue;
    T[il].push_back(mp(ir,i));
    T[ir].push_back(mp(il,i));
  }
  for(int i = 1; i <= n; i ++ ){
    if(!vis[i]){
      if(dfs(i)){
        cout << "-1\n";
        return 0;
      }
    }
  }
  vector<int> ans;
  for(int i = 0 ; i < m ; i ++ ){
    if(use[i])
      ans.push_back(i + 1);
  }
  cout << ans.size() << "\n";
  for(auto x : ans) cout << x << " ";
  return 0;
}

Measured memory_bytes: 14448
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9+7;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll n;
ll a[111111];
ll ans=1e18;

ll gv_1(void)
{
	ll ps=0, ret=0, i;
	for(i=1 ; i<=n ; i++)
	{
		ps+=a[i];
		if(i%2==1)
		{
			if(ps>0) continue;
			if(ps<=0) ret+=(1-ps);
			if(ps<=0) ps=1;
		}
		if(i%2==0)
		{
			if(ps<0) continue;
			if(ps>=0) ret+=(ps+1);
			if(ps>=0) ps=-1;
		}
	}
	return ret;
}

ll gv_2(void)
{
	ll ps=0, ret=0, i;
	for(i=1 ; i<=n ; i++)
	{
		ps+=a[i];
		if(i%2==0)
		{
			if(ps>0) continue;
			if(ps<=0) ret+=(1-ps);
			if(ps<=0) ps=1;
		}
		if(i%2==1)
		{
			if(ps<0) continue;
			if(ps>=0) ret+=(ps+1);
			if(ps>=0) ps=-1;
		}
	}
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n; int i;
	for(i=1 ; i<=n ; i++) cin>>a[i];
	ans=min(ans,gv_1());
	ans=min(ans,gv_2());
	cout<<ans; return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){

  vector <int> ans;
  for (int i = 2; i <= 55555; i++){
    bool flag = false;
    for (int j = 2; j * j <= i; j++){
      if (i % j == 0){
        flag = true;
      }
    }
    if (flag == false && i % 5 == 1){
      ans.push_back(i);
    }
  }
  
  int N; cin >> N;

  for (int i = 0; i < N; i++){
    cout << ans[i];
    if (i == N - 1) cout << endl;
    else cout << " ";
  }
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin >> n;
    vi d(n);
    REP(i, n) cin >> d[i];
    ll a = 0, b = 0;
    REP(i, n){
        ll x;
        cin >> x;
        x = d[i] - x;
        if (x > 0) b += x;
        else a -= x / 2;
    }
    cout << ((a < b) ? "No" : "Yes") << endl;
    return 0;
}


Measured memory_bytes: 256
h,w,a,b=map(int,input().split())
mod=10**9+7
fact=[1]*(h+w+1)
for i in range(1,h+w+1):
    fact[i]=(fact[i-1]*i)%mod
def cmb(a,b):
    return fact[a]*pow(fact[b],mod-2,mod)*pow(fact[a-b],mod-2,mod)%mod
ans=0
for i in range(b,w):
    ans+=cmb(h-a+i-1,i)*cmb(w-1-i+a-1,w-i-1)%mod
print(ans%mod)


Measured memory_bytes: 10868
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    ll cnt=0;
    rep(i,n){
        if(a[i]*4*m>=sum) cnt++;
    }
    if(cnt>=m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
*/

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,p;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  ll dp[2]={0};
  
  scanf("%lld %lld",&n,&p);
  rep(i,n){
    scanf("%d",&a[i]);
    dp[a[i]%2]++;
  }
  
  if(p==0){
    for(i=0;i<=dp[1];i+=2){
      result+=nCr(dp[1],i);
    }
  }else{
    for(i=1;i<=dp[1];i+=2){
      result+=nCr(dp[1],i);
    }
  }
  result *= (ll)powl(2,dp[0]);
  printf("%lld",result);
  
  return 0;
}



Measured memory_bytes: 2304
#include <stdio.h>
#include <vector>
#include <set>

std::set<int> S[300010];
std::vector<int> V1,V2;
int count1[300010],count2[300010];

int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=1;i<=c;i++)
	{
		int d,e;
		scanf("%d%d",&d,&e);
		count1[d]++;
		count2[e]++;
		S[d].insert(e);
	}
	
	int max1 = count1[1];
	for(int i=2;i<=a;i++) max1 = max1>count1[i]?max1:count1[i];
	int max2 = count2[1];
	for(int i=2;i<=b;i++) max2 = max2>count2[i]?max2:count2[i];
	
	for(int i=1;i<=a;i++) if(count1[i]==max1) V1.push_back(i);
	for(int i=1;i<=b;i++) if(count2[i]==max2) V2.push_back(i);
	
	for(int i=0;i<V1.size();i++)
	{
		for(int j=0;j<V2.size();j++)
		{
			if(S[V1[i]].find(V2[j])==S[V1[i]].end())
			{
				printf("%d",max1+max2);
				return 0;
			}
		}
	}
	printf("%d",max1+max2-1);
}

Measured memory_bytes: 37492
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        StringBuilder output = new StringBuilder();
        int n = scan.nextInt();
        for (int i = 3; i <= n; i++) {
            if ((i % 3) == 0) {
                output.append(" ").append(i);
            } else  {
                int x = i;
                while (x != 0) {
                    if ((x % 10) == 3) {
                        output.append(" ").append(i);
                        break;
                    }
                    x /= 10;
                }
            }
        }
        System.out.println(output);
    }
}

Measured memory_bytes: 27536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    int n,k;
    cin >> n >> k;
    cout <<  (n-k+1) << endl;
    return 0;
}

Measured memory_bytes: 256
N = 8
ptn=[[(0,0),(0,1),(1,0),(1,1)], [(0,0),(1,0),(2,0),(3,0)],
    [(0,0),(0,1),(0,2),(0,3)], [(0,1),(1,0),(1,1),(2,0)],
    [(0,0),(0,1),(1,1),(1,2)], [(0,0),(1,0),(1,1),(2,1)],
    [(0,1),(0,2),(1,0),(1,1)]]

def readdata():
    x = ""
    while x=="":
        try: x=raw_input()
        except: return []
    x=[x]    
    for i in range(N-1):
        x.append(raw_input())
    return x

def f0036(x):
    try: return "ABCDEFG"[ptn.index(x)]
    except: return False

while True:
    dt = readdata()
    if dt==[]: break

    xx=[]
    yy=[]
    for y in range(N):
        e = dt[y]
        try: x = e.index("1")
        except: continue
        while x < N:
            if e[x]=="1":
                xx.append(x)
                yy.append(y)
            x = x+1
    p = zip([e-min(yy) for e in yy], [e-min(xx) for e in xx])
    print f0036(p)

Measured memory_bytes: 4324
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
   string n;cin>>n;
   if(n.size()==1){
       cout<<n<<endl;
       return 0;
   }
   ll res=(n.size()-1)*9;
   bool isNine = true;
   for(int i = 1; i < n.size(); ++i){
       if(n[i]!='9')isNine=false;
   }
   ll a=n[0] - '0';
   if(!isNine){
       --a;
   }
   res+=a;
   cout<<res<<endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    q = int(input())
    sum_a = sum(a_list)

    a_dict = {}
    for a in a_list:
        if a not in a_dict:
            a_dict[a] = 1
        else:
            a_dict[a] += 1

    for _ in range(q):
        b, c = map(int, input().split())

        if b not in a_dict:
            a_dict[b] = 0
        sum_a += (c - b) * a_dict[b]

        if c not in a_dict:
            a_dict[c] = 0
        a_dict[c] += a_dict[b]
        a_dict[b] = 0

        print(sum_a)


if __name__ == "__main__":
    main()


Measured memory_bytes: 94532
import static java.lang.System.out;
import java.io.InputStream;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {
	public static void main(String args[]) {
		MyInput in = new MyInput();
    String input = in.next();
    String[] a = input.split("");
    int c = 0;
    for(String s: a) {
        if(s.equals("1"))c++;
    }
    out.println(c);

	}
}

class MyInput {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr= 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		}else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch(IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	public int readByte() {
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <=126;
	}

	private void skipUnprintable() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if(!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if(!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if(b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true) {
			if('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			}else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if(nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}



Measured memory_bytes: 23252
n,w = map(int,input().split())
v = 10**5
dp = [[n*w+1]*(v+1) for i in range(n)]
ans = 0
for i in range(n):
    W,V = map(int,input().split())
    if i == 0:
        for j in range(v+1):
            if j <= V:
                dp[0][j] = W
    else:
        for j in range(v+1):
            if j <= V:
                dp[i][j] = min(dp[i-1][j], W)
            else:
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-V]+W)
kouho = dp[-1]
for i in range(v+1):
    if kouho[i] <= w:
        ans = i
print(ans)

Measured memory_bytes: 120172
#include <iostream>

using namespace std;

bool use[10];
int us[10];
int keta[10];

int main(){
    int n,k;
    cin >> n >> k;
    int id;
    for(int i=0;i<10;i++) use[i] = true;
    for(int i=0;i<k;i++){
        cin >> id;
        use[id] = false;
    }
    
    int base = 10-k;
    int j=0;
    for(int i=0;i<10;i++){
        if(use[i]){
            us[j] = i;
            j++;
        }
    }
    
    
    for(int k=n;k<100000;k++){
        
        int c = k;
        bool f = true;
        for(int i=0;i<7;i++){
            f = f&&use[c%10];
            c = c/10;
            if((!f) ||c==0) break;
        }
        if(f){
            cout << k << endl;
            return 0;
        }
        
        
    }
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
int dx[] = {0, 1, 1, 0, -1, -1};
int dy[] = {1, 1, 0, -1, -1, 0};

struct state {
	int x, y, t;
	state(int xx, int yy, int tt) {
		x = xx;
		y = yy;
		t = tt;
	}
};

int main() {
	int t, n;

	while(cin >> t >> n, t) {
		vvi field(121, vi(121, 0));
		queue<state> Q;

		int x, y;
		REP(i, n) {
			cin >> x >> y;
			field[x+60][y+60] = 1;
		}

		int sx, sy;
		cin >> sx >> sy;
		Q.push(state(sx, sy, 0));
		field[sx+60][sy+60] = 1;
		int count = 1;

		while(!Q.empty()) {
			state st = Q.front();
			Q.pop();
			REP(d, 6) {

					if(field[st.x+dx[d]+60][st.y+dy[d]+60] == 0) {
						field[st.x+dx[d]+60][st.y+dy[d]+60] = 1;
						count++;
						if(st.t+1 < t) {
							Q.push(state(st.x+dx[d], st.y+dy[d], st.t+1));
						}
					}

			}
		}

		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 1284
import sys
readline = sys.stdin.readline

def main():
    N = int(readline())
    l0 = 2
    l1 = 1
    if N == 1:
        print(l1)
        return
    for i in range(2, N+1):
        li = l0 + l1
        l0 = l1
        l1 = li
    print(li)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
def f_c():

    n = int(input())
    d = {}
    dc = {}
    for _ in range(n):
        s = "".join(sorted(input()))
        if s in d:
            dc[s] += d[s]
            d[s] += 1
        else:
            d[s] = 1
            dc[s] = 0
    print(sum(dc.values()))

if __name__ == "__main__":
    f_c()


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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 100111, inf = 1000111222;

int v[max_n];
vector<pair<int, pair<int, int>>> e;

int sz[max_n];
int pr[max_n];
ll sumv[max_n];
ll cnte[max_n];
ll sete[max_n];
int n, m;


int get_set(int a) {
    if (pr[a] == a) {
        return a;
    } else {
        return pr[a] = get_set(pr[a]);
    }
}

int ans = 0;

void unite_set(int a, int b, int w) {
    int pra = get_set(a);
    int prb = get_set(b);
    if (pra == prb) {
        int pr = pra;
        if (w <= sumv[pr]) {
            ans++;
            cnte[pr]++;
            sete[pr]++;
            if (cnte[pr] != sete[pr]) {
                exit(228);
            }
        } else {
            cnte[pr]++;
        }
        return;
    }
    ll n_sumv = sumv[pra] + sumv[prb];
    ll n_cnte;
    ll n_sete;
    if (w <= n_sumv) {
        ans -= sete[pra];
        ans -= sete[prb];
        n_cnte = cnte[pra] + cnte[prb] + 1;
        n_sete = n_cnte;
        ans += n_cnte;
    } else {
        n_cnte = cnte[pra] + cnte[prb] + 1;
        n_sete = sete[pra] + sete[prb];
    }
    if (sz[pra] > sz[prb]) {
        sz[pra] += sz[prb];
        pr[prb] = pra;
        sumv[pra] = n_sumv;
        cnte[pra] = n_cnte;
        sete[pra] = n_sete;
    } else {
        sz[prb] += sz[pra];
        pr[pra] = prb;
        sumv[prb] = n_sumv;
        cnte[prb] = n_cnte;
        sete[prb] = n_sete;
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    for (int i = 0; i < m; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        e.push_back(MP(c, make_pair(a, b)));
    }
    for (int i = 0; i < n; ++i) {
        sz[i] = 1;
        pr[i] = i;
        sumv[i] = v[i];
        cnte[i] = sete[i] = 0;
    }
    sort(e.begin(), e.end());
    for (int i = 0; i < e.size(); ++i) {
        int a = e[i].S.F, b = e[i].S.S;
        int c = e[i].F;
        unite_set(a, b, c);
    }
    cout << (m - ans) << endl;
    return 0;
}




Measured memory_bytes: 5108
#include <stdio.h>
#include <inttypes.h>

int N;
int A[222222];

int asumisu[222222];
uint64_t mizuhasu[222222];
uint64_t mamegu;

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
		asumisu[A[i]]++;
	}
	mamegu = 0;
	for (i = 1; i <= N; i++) {
		mizuhasu[i] = (uint64_t)asumisu[i] * (asumisu[i] - 1) / 2;
		mamegu += mizuhasu[i];
	}
	for (i = 0; i < N; i++) {
		uint64_t emirinn = mamegu - mizuhasu[A[i]];
		printf("%" PRIu64 "\n", emirinn + (uint64_t)(asumisu[A[i]] - 1) * (asumisu[A[i]] - 2) / 2);
	}
	return 0;
}


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define LL long long
#define ULL unsigned long long

// n개중에서 k 를 고르는 Combination table을 미리 세팅한다.
// C[n][k] -> nCk
ULL Comb[51][51];
void combination_table(int n)
{
    for(int i = 0; i <= n; ++i)
        for(int j = 0; j <= i; ++j)
        {
            if(j == 0 || j == i)
                Comb[i][j] = 1ll;
            else
                Comb[i][j] = Comb[i - 1][j - 1] + Comb[i - 1][j];
        }
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    int N, A, B;
    cin >> N >> A >> B;

    VL items(N, 0);
    REP(i, 0, N) cin >> items[i];

    combination_table(N);
    sort(items.begin(), items.end(), greater<LL>());

    double max_avg = (double)accumulate(items.begin(), items.begin() + A, 0ll) / A;
    
    LL smallest = items[A - 1];
    int numSmallest = count(items.begin(), items.end(), smallest);
    
    LL cnt = 0ll;
    // 1. items[0] == items[A - 1] 인 경우    
    if(items[0] == smallest)
        cnt += accumulate(Comb[numSmallest] + A, Comb[numSmallest] + B + 1, 0ll);
    else {
        int numSub = count(items.begin(), items.begin() + A, smallest);
        cnt += Comb[numSmallest][numSub];
    }

    cout.precision(10);
    cout << fixed << max_avg << endl << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)    for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define rrep(i, n)   for(int i=(n-1); i>=0; --i)
#define all(v)       v.begin(), v.end()
#define rall(v)      v.rbegin(), v.rend()
#define int          long long
template<typename T>
using vv  = vector<vector<T>>;
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using P   = pair<int, int>;
using ll  = long long;
constexpr ll INF = 1LL << 60;

signed main(){

    string s, t;
    cin >> s >> t;

    int ans = 0;
    rep(i, s.size()){
        if(s[i] != t[i]){
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3848
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define rep(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)


#define endl '\n'


template<class T=int> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y); }


class Solution {
public:
    int ans = 5000, dp[41][401][401];
    int a[41], b[41], c[41], n, ma, mb;

    void recur(int x, int asum, int bsum, int cost) {
        int g = gcd(asum, bsum);
        if (g > 0 and asum / g == ma and bsum / g == mb) ans = min(ans, cost);
        if (dp[x][asum][bsum] < cost) return;
        dp[x][asum][bsum] = cost;
        if (x == n) return;
        recur(x+1, asum+a[x+1], bsum+b[x+1], cost+c[x+1]);
        recur(x+1, asum, bsum, cost);
    }

    void solve(std::istream& in, std::ostream& out) {
        in >> n >> ma >> mb;
        rep(i, 1, n+1, 1) {
            in >> a[i] >> b[i] >> c[i];
        }
        rep(i, 0, 41, 1) rep(j, 0, 401, 1) rep(k, 0, 401, 1) dp[i][j][k] = 5000;
        recur(0, 0, 0, 0);
        if (ans == 5000) ans = -1;
        out << ans << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




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

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

    int imin = -1000000;
    int imax = 1000000;

    imin = max(imin,X - (K - 1));
    imax = min(imax,X + (K - 1));

    for (int i = imin; i <= imax; i++) {
        if (imin < i) cout << " ";
        cout << i;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

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

mod = 10 ** 9 + 7

sum = 0

for i in range(k, n + 2):
    
    min_value = int(i * (i - 1) / 2)
    max_value = int(i * (2 * n - i + 1) / 2)
    
    sum += max_value - min_value + 1

print(sum % mod)


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int x = s.ToCharArray().Count(c => c == 'o');
            Console.WriteLine(700 + x * 100);
        }
    }
}

Measured memory_bytes: 13268