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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const int INF = INT_MAX;

template<typename T> inline constexpr auto sqr(T x) { return (x) * (x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }

signed main()
{
	int X, Y, Z;
	cin >> X >> Y >> Z;

	int a = Z, b = X, c = Y;

	cout << a << ' ' << b << ' ' << c << endl;

	return 0;
}

Measured memory_bytes: 256
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_6-C: Quick Sort

#include <algorithm>
#include <cstdio>

using uint = unsigned int;

struct Card {
  char suit;
  uint rank;
  uint index; // for stable check

  void set(char s, uint r, uint i)
  {
    suit = s;
    rank = r;
    index = i;
  }

  void print() const
  {
    std::printf("%c %u\n", suit, rank);
  }
};

static void print_cards(const Card cards[], const uint n)
{
  for (auto i = 0u; i < n; ++i) {
    cards[i].print();
  }
}

static bool is_stable(const Card cards[], const uint n)
{
  for (auto i = 0u; i< n-1; ++i) {
    if (cards[i].rank == cards[i+1].rank &&
        cards[i].index > cards[i+1].index) {
      return false;
    }
  }
  return true;
}

static uint partition(Card cards[], uint begin, uint end)
{
  auto last = end-1;
  auto gt = begin;
  for (auto i = begin; i < last; ++i) {
    if (cards[i].rank <= cards[last].rank) {
      std::swap(cards[gt++], cards[i]);
    }
  }
  std::swap(cards[gt], cards[last]);
  return gt;
}

static void quick_sort(Card cards[], uint begin, uint end)
{
  if (end - begin > 1) {
    auto middle = partition(cards, begin, end);
    quick_sort(cards, begin, middle);
    quick_sort(cards, middle+1, end);
  }
}

int main()
{
  uint n;
  std::scanf("%u", &n);
  Card cards[n];
  for (uint i = 0; i < n; ++i) {
    char s;
    uint r;
    std::scanf(" %c %u", &s, &r); // skip space
    cards[i].set(s, r, i);
  }

  quick_sort(cards, 0u, n);

  std::puts(is_stable(cards, n) ? "Stable" : "Not stable");
  print_cards(cards, n);
}

// eof

Measured memory_bytes: 3792
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;

int main() {
	int n, l;
	int sum = 0;
	cin >> n >> l;
	if (l >= 0) {
		rep(i, 1, n)sum += l + i;
	}
	else if (l + n - 1 <= 0) {
		rep(i, 0, n - 1)sum += l + i;
	}
	else {
		rep(i, 0, n)sum += l + i;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
  
using namespace std;
  
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)



int main(){
	while(1){
	string cc[333];
	
	cc[' ']="101";
	cc['\'']="000000";
	cc[',']="000011";
	cc['-']="10010001";
	cc['.']="010001";
	cc['?']="000001";
	
	cc['A']="100101";
	cc['B']="10011010";
	
	cc['C']="0101";
	cc['D']="0001";
	cc['E']="110";
	cc['F']="01001";
	cc['G']="10011011";
	cc['H']="010000";
	cc['I']="0111";
	cc['J']="10011000";
	
	cc['K']="0110";
	cc['L']="00100";
	cc['M']="10011001";
	cc['N']="10011110";
	cc['O']="00101";
	cc['P']="111";
	cc['Q']="10011111";
	cc['R']="1000";
	
	cc['S']="00110";
	cc['T']="00111";
	cc['U']="10011100";
	cc['V']="10011101";
	cc['W']="000010";
	cc['X']="10010010";
	cc['Y']="10010011";
	cc['Z']="10010000";
	
	
	map<int,char> dd;
	rep(i,26){
		dd[i]='A'+i;
	}
	dd[26]=' ';
	dd[27]='.';
	dd[28]=',';
	dd[29]='-';
	dd[30]='\'';
	dd[31]='?';
	
	
	string str="";
	string in;
	while(1){
		getline(cin,in);
		if(cin.eof())break;
		if(str.size()!=0)str+=" ";
		str += in;
		break;
	}
	
	if(cin.eof())break;
	
	
	string conv="";
	rep(i,str.size()){
		conv += cc[str[i]];
	}
	
	while(conv.size()%5!=0){
		conv += "0";
	}
	string ans;
	
	for(int i=0;i<conv.size();i+=5){
		
		int num = 0;
		rep(j,5){
			num += (conv[i+j]-'0')*(1<<(4-j));
		}
		
		ans += dd[num];
	}
	
	cout<<ans<<endl;
	}
}

Measured memory_bytes: 1196
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
const int N=1E6+7;
vector<int>ve[N];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		ve[x].push_back(y);
	}
	for(int i=1;i<=m;i++){
		sort(ve[i].begin(),ve[i].end());
	}
	priority_queue<int >que;
	int ans=0;
	for(int i=1;i<=m;i++){
		for(int j=0;j<ve[i].size();j++){
			que.push(ve[i][j]);
		}
		if(que.size()){
				ans+=que.top();
				que.pop();
		}
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 26752
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

const int MAXN = 110;
int a[MAXN];

int main(void) {
    int n, A, B, C;
    cin >> n;
    cin >> A >> B;
    cin >> C;
    int sum = C;
    int price = A;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a+n);
    for (int i = n-1; i >= 0; i--) {
        if (1.0*sum/price < 1.0*(sum+a[i])/(price+B)) {
            sum += a[i];
            price += B;
        } else break;
    }
    cout << sum / price << endl;
    return 0;
}

Measured memory_bytes: 1176
#include <iostream>

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	if ((a < b) && (b < c))
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}
	return 0;
}


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

int a[20005], b[20005], r[20005];
int main() {
    int n;
    cin >> n;
    int p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        r[p[i]] = i + 1;
    }
    for (int i = 0; i < n; i++) {
        a[i] = 30000 * (i + 1);
        b[i] = 30000 * (n - i + 1) + r[i + 1];
    }
    for (int i = 0; i < n; i++) cout << a[i] << (i == n - 1 ? "\n" : " ");
    for (int i = 0; i < n; i++) cout << b[i] << (i == n - 1 ? "\n" : " ");
    return 0;
}

Measured memory_bytes: 896
xy = [map(int, input().split()) for _ in range(7)]
x, y = [list(i) for i in zip(*xy)]
print(x[0]-y[0])
print(x[1]-y[1])
print(x[2]-y[2])
print(x[3]-y[3])
print(x[4]-y[4])
print(x[5]-y[5])
print(x[6]-y[6])


Measured memory_bytes: 5604
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll A(N);
  bool all0 = true;
  REP(i, 0, N) {
    cin >> A[i];
    if (A[i] != 0) {
      all0 = false;
    }
  }
  if (all0) {
    cout << "Yes" << endl;
    return 0;
  }

  ll xo = 0;
  for (const auto& a : A) {
    xo ^= a;
  }
  cout << (xo ? "No" : "Yes") << endl;
  return 0;


}


Measured memory_bytes: 1024
#include<iostream>
#include<numeric>
#include<cmath>
#include<vector>
#include<algorithm>
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
	int n;
	uli sum = 0;
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			for(int k = 1; k <= n; ++k) {
				int mi=min(min(i, j), k);
				int num = 0;
				for(int l = 1; l <= mi; ++l) {
					if(i % l == 0 && j % l == 0 && k % l == 0)
						num = l;
				}
				sum += num;
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	void solve() {
		const int c = 26;

		long N;
		cin >> N;
		string ans;
		while( N > 0 ) {
			ans.push_back( "abcdefghijklmnopqrstuvwxyz"[(N-1) % c] );
			N = (N-1) / c;
		}
		reverse( ans.begin(), ans.end() );
		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    string s;
    int i;

    cin >> s;

    for(i=0; i<s.size(); i++){
        cout << 'x';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

def main():
    takahashi_physical,takahashi_offensive,aoki_physical,aoki_offensive = map(int,input().split())
    
    offence_turn = 0
    while True:
        offence_turn = offence_turn % 2
        
        if offence_turn == 0:
            aoki_physical -= takahashi_offensive
        else:
            takahashi_physical -= aoki_offensive
        
        if takahashi_physical <= 0:
            break
        if aoki_physical <= 0:
            break
        offence_turn += 1
        
    if offence_turn == 0:
        print("Yes")
    else:
        print("No")
    

if __name__ == "__main__":
    main()
    


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

constexpr int MOD = 1'000'000'007;

template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(long long e){
        long long a = 1, p = x;
        while(e > 0) {
            if (e & 1) {a = (a * p) % mod; e--;}
            else {p = (p * p) % mod; e /= 2;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

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

    vector<int> a(2 * n); // 0 : L, 1 : R
    a[0] = 0;
    for (int i = 1; i < 2 * n; i++) {
        a[i] = a[i - 1] ^ (s[i] == s[i - 1]);
    }

    if (s[0] == 'W' or s[2 * n - 1] == 'W') {
        cout << 0 << '\n';
        return 0;
    }

    int val = 0;
    ModInt<MOD> ans = 1;
    for (int e : a) {
        if (e) ans *= val--;
        else val++;
    }

    for (int i = 0; i < n; i++) {
        ans *= (i + 1);
    }
    
    cout << ans * (val == 0) << '\n';

    return 0;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
int main()
{
char s[101];
  cin>>s;
  int i=0;
  while(s[i]!='\0')
  {
i++;
  }
 int  n =i-1;
  int c=0;
  for(int i=0,j=n;i<=j;i++,j--)
  {
    if(s[i]!=s[j])
      c++;
  }
  cout<<c<<endl;
  return  0;
}


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

int main(){
    int A[5][4][11],n;
    for ( int i = 1; i <= 4; i++) 
        for( int j = 1; j <=3; j++) 
            for( int k = 1; k <=10; k++) A[i][j][k] = 0;
            
    cin >> n;
    for(int i = 0; i <  n; i++){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        A[b][f][r] = A[b][f][r] + v;
    }
    
    for ( int f = 1; f <= 4; f++){
        if (f > 1) cout << "####################\n";
        for(int b = 1; b <= 3; b++){
            for(int r = 1; r <= 10; r++){
                cout << " " << A[f][b][r];
            }
            cout << endl;
        }
    }
    return 0;
    
}


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


Measured memory_bytes: 32432
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int a,b,n;
    while(cin>>a>>b>>n){
        a%=b;
        int sum=0;
        for(int i=0;i<n;i++){
            a*=10;
            sum+=a/b;
            a%=b;
        }
        cout<<sum<<endl;
    }
    return 0;
}

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

int cnt(bitset<15> bs) {
    int ans = 0;
    for (int i = 0; i < 15; ++i) ans += bs.test(i);
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<vector<vector<int>>> data(n, vector<vector<int>>(0, vector<int>(2)));
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        for (int j = 0; j < a; ++j) {
            int x, y;
            cin >> x >> y;
            --x;
            data[i].push_back({x, y});
        }
    }
    int ans = 0;
    for (int k = 0; k < (1 << n); ++k) {
        bitset<15> bs(k);
        bool flag2 = false;
        for (int i = 0; i < n; ++i) {
            bool flag = false;
            for (vector<int> v : data[i]) {
                if (!bs.test(i)) continue;
                if ((v[1] == 1 && !bs.test(v[0])) || (v[1] == 0 && bs.test(v[0]))) {
                    flag = true;
                    break;
                }
            }
            if (flag) {
                flag2 = true;
                break;
            }
        }
        if (!flag2) ans = max(ans, cnt(bs));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.util.*;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main{
    //WRWWRWRR     wwwrrrrwwwwrrr
    PriorityQueue<int[]> pq = new PriorityQueue<>((a,b)->(a[0]-b[0]));
    public void solve(int testNumber, InputReader in, PrintWriter out) {
       int n = in.nextInt();
       int p = in.nextInt();
       char[] cs = in.next().toCharArray();
       long mut = 1;
       long tot = 0;
       Map<Long,Long> mp = new HashMap<>();
       long mod = p;
       long res = 0;
       mp.put((long)0,(long)1);
       if(p==2||p==5){
           for(int i=0;i<n;i++){
               int v = cs[i]-'0';
               if(v%p==0){
                   res+=i+1;
               }
           }
           out.println(res);
           return;
       }
       for(int i=n-1;i>=0;i--){
           int v = cs[i]-'0';
           long add = mut*v;
           add%=mod;
           tot = (tot+add)%mod;
           if(mp.containsKey(tot)){
               res+=mp.get(tot);
           }
           mp.put(tot,mp.getOrDefault(tot,(long)0)+1);
           mut*=10;
           mut%=mod;
       }
       out.println(res);
    }


    public static void main(String[] args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Main solver = new Main();
//        int num = in.nextInt();
//        while(num-->0){
//            solver.solve(1, in, out);
//        }
        solver.solve(1, in, out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 54916
/* ABC174 C.c */

#include<stdio.h>
#include<math.h>

int main(void){
    long long k, remain=0, i=0, j;
    scanf("%lld", &k);
    long long rest[k];

    for(j=0; j<k; j++){
        rest[j] = 0;
    }

    //count = i+1
    while(1){
        remain = (remain*10+7)%k;
        if(remain==0){
            printf("%lld\n", i+1);
            break;
        }else if(rest[remain]!=0){
            printf("-1\n");
            break;
        }else{
            rest[remain]=1;
            i++;
        }
    }

    return 0;
}


Measured memory_bytes: 9468
from collections import defaultdict

N = int(input())
S = [input() for _ in range(N)]

answer = 0
counter = defaultdict(int)

for s in S:
  tmp = 0
  ss = list(s)
  ss.sort()
  for i in range(10):
    tmp += (ord(ss[i]) - ord("a")) * 26 ** i
  answer += counter[tmp]
  counter[tmp] += 1
  
print(answer)

Measured memory_bytes: 23240
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(string& s) {
        const int N = 2019;
        vector<long long> dp(N, 0);
        vector<long long> ndp(N, 0);
        int n = s.length();
        long long res = 0;
        for (int i = 0; i < n; ++i) {
            int d = s[i] - '0';
            dp[0] += 1;
            fill(ndp.begin(), ndp.end(), 0);
            for (int j = 0; j < N; ++j) {
                if (dp[j] == 0) {
                    continue;
                }
                // cout << i << " " << j << " " << dp[j] << endl;
                int nj = (j << 3) + (j << 1) + d;
                // int nj = j * 10 + d;
                nj %= N;
                ndp[nj] += dp[j];
            }
            swap(ndp, dp);
            res += dp[0];
        }

        
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    Solution sol;
    cout << sol.solve(s) << "\n";

    return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
using namespace std;

int main()
{
	string s;

	cin >> s;

	unsigned long long tmpb = 0;
	unsigned long long cnt = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'B')
		{
			tmpb++;
		}
		else
		{
			cnt += tmpb;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>

#define N 20

int main() {
    int V[N], C[N];
    int ans = 0, n;
    std::cin >> n;
    for (int i=0; i<n; ++i) {
        std::cin >> V[i];
    }
    for (int i=0; i<n; ++i) {
        std::cin >> C[i];
    }
    for (int i=0; i<n; ++i) {
        ans += std::max(V[i]-C[i], 0);
    }
    std::cout <<  ans << std::endl;
    return  0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int A, B;	cin >> A >> B;
	string S;	cin >> S;
	if (S.size() != A + B + 1) {
		cout << "No" << endl;
		cin >> A;
		return 0;
	}
	if (S[A] != '-') {
		cout << "No" << endl;
		cin >> A;
		return 0;
	}
	S[A] = '0';
	for (int i = 0; i < S.size(); ++i) {
		if (S[i] == '-') {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	cin >> A;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    set<int> s(ALL(A));
    if (s.size() == A.size()) {
        cout << "YES" << endl;
    } else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n;
  if(n>9000)
  {
    cout<<10000-n;
  }
  else if(n>8000)
  cout<<9000-n;
  else if(n>7000)
  cout<<8000-n;
  else if(n>6000)
  cout<<7000-n;
  else if(n>5000)
  cout<<6000-n;
  else if(n>4000)
  cout<<5000-n;
  else if(n>3000)
  cout<<4000-n;
  else if(n>2000)
  cout<<3000-n;
  else if(n>1000)
  cout<<2000-n;
  else cout<<1000-n;
  }
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

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


int main(int argc, char *argv[]){
  int card_num;
  cin >> card_num;
  
  int card[card_num];
  for(int i=0; i<card_num; i++) cin >> card[i];
  
  sort(card, card+card_num, greater<int>());
  int Alice = 0;
  int Bob = 0;
  
  for(int i=0; i<card_num; i++){
    if(i%2==0) Alice += card[i];
    else Bob += card[i];
  }
  
  printf("%d", Alice-Bob);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 1e4+50;
const ll oo = 1e18;
const ll mod = 1e9+7;


int main(){
    // 9opl.
    int n,k;
    scanf("%d%d",&n,&k);
    vector<ll>v1,v2;
    for(int i=0;i<n;i++){
        ll a;
        scanf("%lld",&a);
        if(a==0){
            k--;
            continue;
        }
        if(a<0)
            v1.push_back(-a);
        else
            v2.push_back(a);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    ll mn=1e18;
    if(k==0)
        mn=0;
    if(k-1<v1.size())
        mn=min(mn,v1[k-1]);
    if(k-1<v2.size())
        mn=min(mn,v2[k-1]);
    for(int i=0;i<v1.size();i++){
        if(k-i-2>=0&&k-i-2<v2.size())
            mn=min(mn,2LL*v1[i]+v2[k-i-2]);
        if(i==0){
            if(k-i-1>=0&&k-i-1<v2.size())
                mn=min(mn,v2[k-i-1]);
        }
        else{
            if(k-i-1>=0&&k-i-1<v2.size())
                mn=min(mn,2LL*v1[i-1]+v2[k-i-1]);
        }
    }
    for(int i=0;i<v2.size();i++){
        if(k-i-2>=0&&k-i-2<v1.size())
            mn=min(mn,2LL*v2[i]+v1[k-i-2]);
        if(i==0){
            if(k-i-1>=0&&k-i-1<v1.size())
                mn=min(mn,v1[k-i-1]);
        }
        else{
            if(k-i-1>=0&&k-i-1<v1.size())
                mn=min(mn,2LL*v2[i-1]+v1[k-i-1]);
        }
    }
    cout<<mn<<endl;
    return 0;
}


Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long
#define fi first
#define se second
#define ii  pair<int, int>
#define vi  vector <int>
#define vii vector <pair <int, int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 200010
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")


ll n, k; 
vector <ll> a(range), cost(range);

ll total_reduce(ll x) {
    ll ans = 0;
    forn(i, n) {
        ans += max(a[i] - x / cost[i], 1LL * 0);
    }
    return ans;
}

int main(){

    //freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();

    cin >> n >> k;
    a.resize(n);
    cost.resize(n);
    forn(i, n) cin >> a[i];
    forn(i, n) cin >> cost[i];
    ll l = 0, r = 0;


    sort(all(a));
    sort(all(cost));
    reverse(all(cost));

    forn(i, n) {
        r = max(r, 1LL * cost[i] * a[i]);
    }   
    ll pos_ans = r;
    while(l <= r) {
        ll mid = (l + r) / 2;
        ll p = total_reduce(mid);
        if(p <= k) {
            pos_ans = min(pos_ans, mid);
            r = mid - 1;
        }
        else l = mid + 1;
    }

    cout << pos_ans << endl;

    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


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

typedef long long ll;

ll zerosf(ll n) {
	if (n == 0 || n % 2) return 0;
	ll ans = 0;
	n /= 10;
	ans += n;
	while (n != 0) {
		n /= 5;
		ans += n;
	}
	return ans;
}

int main() {
	ll n;
	cin >> n;
	printf("%lld\n", zerosf(n));
	return 0;
}

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

int n, a, b;
std::map<int, int> m;
int max_b = 0;
int ans = 0;
int sum = 0;

int main() {
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a >> b;
        m[a]++;
        m[b+1]--;
    }
    for (auto me: m) {
        sum+= me.second;
        ans = std::max(sum, ans);
    }
    std::cout << ans << std::endl;
}



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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a, b, ta, tb;

int main() {
	cin >> n;
	rep(i,n) {
		cin >> ta >> tb;
		if (a<ta) {
			a = ta;
			b = tb;
		}
	}
	cout << a + b << ln;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int a, b;
  char op;
  while(scanf("%d %c %d", &a, &op, &b) && op != '?'){
    if(op == '+') a += b;
    else if(op == '-') a -= b;
    else if(op == '*') a *= b;
    else if(op == '/') a /= b;
    printf("%d\n", a);
  }
  return 0;
}


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

typedef long long ll;

main()
{
    ll n, d, x, y, c = 0;
    cin >> n >> d;
    for(int i = 0; i < n; i++){
        cin >> x >> y;
        ll z = x*x + y*y;
        ll dis = d*d;
        if(z <= dis){
            c++;
        }
    }
    cout << c;


}





///promy_pompom
//hello world


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    string O,E ;
    cin >> O >> E;
    int ocount = O.size(),ecount = E.size();
    int i = 0,j = 0;
    for (int k = 0;k < ecount; k++ ){
        cout << O[i] << E[j];
        i++ , j++ ;
    }
    if (ocount != ecount){
        cout << O[i];
    }
}

Measured memory_bytes: 256
<?php
# C - Rectangle Cutting

fscanf(STDIN, "%d %d %d %d", $W, $H, $x, $y);

$area = ($W * $H) / 2.0;
$how = 0;
if ($x == ($W / 2) && $y == ($H / 2)) {
    $how = 1;
}  

echo $area . ' ' . $how . PHP_EOL;


Measured memory_bytes: 4728
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;


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


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

int main() {
  int N, K, l[64];
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> l[i];
  sort(l, l + N, greater<int>());
  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;

void main() {
    string s = readln.chomp;
    ulong k = readln.chomp.to!ulong;

    if (s[0] != '1') {
        s[0].writeln;
        return;
    }

    foreach(i, c; s) {
        if (c != '1') {
            if (i < k) {
                s[i].writeln;
                return;
            }
        }
    }
    1.writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}


int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
    a[i]--;
  }

  if (N <= 5) {
    vector<int> v(N);
    iota(v.begin(), v.end(), 0);
    do {
      bool ok = true;
      rep(i, N - 1) {
        if (a[v[i]] == v[i + 1])
          ok = false;
      }

      if (ok) {
        rep(i, len(v)) {
          cout << (v[i] + 1) << ((i == len(v) - 1) ? "\n" : " ");
        }
        return 0;
      }
    } while (next_permutation(v.begin(), v.end()));
    puts("-1");
    return 0;
  }

  vector<int> in(N);
  rep(i, N) {
    in[a[i]]++;
  }

  set<int> s;
  rep(i, N) {
    s.insert(i);
  }

  vector<int> ans(N);
  int NG = -1;
  rep(i, N - 4) {
    int x;
    for (auto cand : s) {
      if (NG == cand)
        continue;
      x = cand;
      break;
    }

    if (in[a[x]] == N - 1 - i)
      x = a[x];

    ans[i] = x;
    NG = a[x];
    in[x] = -1;
    in[a[x]]--;
    s.erase(x);
  }

  vector<int> v;
  for (auto elem : s) {
    v.pb(elem);
  }

  do {
    rep(i, 4) {
      ans[N - 4 + i] = v[i];
    }
    bool ok = true;

    rep(i, 4) {
      if (a[ans[N - 5 + i]] == ans[N - 5 + i + 1])
        ok = false;
    }
    if (ok) {
      rep(i, len(ans)) {
        cout << (ans[i] + 1) << ((i == len(ans) - 1) ? "\n" : " ");
      }
      return 0;
    }
  } while (next_permutation(v.begin(), v.end()));

  puts("-1");
  return 0;
}

Measured memory_bytes: 6656
use std::collections::HashMap;

fn main() {
    proconio::input! {
        n: usize,
        sc: [(String, u64); n],
    }

    let rev: Vec<_> = sc
        .iter()
        .map(|(s, _)| s.chars().rev().collect::<String>())
        .collect();

    let mut cost = u64::max_value();
    for i in 0..n {
        let mut solver = Solver::new(n, &sc, &rev);
        cost = cost.min(if sc[i].0 == solver.rev[i] {
            sc[i].1
        } else {
            solver.calc(sc[i].0.as_str(), sc[i].1, true)
        });
    }

    if cost < u64::max_value() {
        println!("{}", cost);
    } else {
        println!("-1");
    }
}

struct Solver<'a> {
    done: HashMap<(&'a str, bool), u64>,
    n: usize,
    sc: &'a Vec<(String, u64)>,
    rev: &'a Vec<String>,
}

impl<'a> Solver<'a> {
    fn new(n: usize, sc: &'a Vec<(String, u64)>, rev: &'a Vec<String>) -> Solver<'a> {
        Solver {
            done: HashMap::new(),
            n: n,
            sc: sc,
            rev: rev,
        }
    }

    fn calc(&mut self, s: &'a str, cost: u64, is_left: bool) -> u64 {
        let mut v = u64::max_value();
        if if let Some(&c) = self.done.get(&(s, is_left)) { cost >= c } else { false } {
            v
        } else {
            self.done.insert((s, is_left), cost);
            for i in 0..self.n {
                let oppo = if is_left { &self.rev[i] } else { &self.sc[i].0 };
                let next = if s.starts_with(oppo) {
                    Some((&s[oppo.len()..], is_left))
                } else if oppo.starts_with(&s) {
                    Some((&oppo[s.len()..], !is_left))
                } else {
                    None
                };
                if let Some((next, is_left)) = next {
                    let cost = cost + self.sc[i].1;
                    v = v.min(if next == next.chars().rev().collect::<String>() {
                        cost
                    } else {
                        self.calc(next, cost, is_left)
                    });
                }
            }
            v
        }
    }
}


Measured memory_bytes: 2220
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#define int long long
#define N 200010
using namespace std;
inline int read()
{
	int neg=1,num=0;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')neg=-1;
	for(;isdigit(c);c=getchar())num=(num<<1)+(num<<3)+c-'0';
	return neg*num;
}
int n,m,Q,tot,fa[N],u[N],v[N],c[N]; 
inline int Find(int x){return fa[x]==x?x:fa[x]=Find(fa[x]);}
inline int Union(int x,int y)
{
	x=Find(x);y=Find(y);
	if(x==y)return 0;
	fa[y]=x;return 1;
}
signed main()
{
	n=read();m=read();Q=read();tot=n;
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<=Q;i++)
	{
		u[i]=read()+1;v[i]=read()+1;c[i]=read();
		if(c[i])continue; 
		tot-=Union(u[i],v[i]);
	}
	if(1ll*tot*(tot-1)/2+n-tot<m)printf("No\n"),exit(0);//ÄÜÁ¬µÄ±ßÌ«ÉÙ 
	for(int i=1;i<=Q;i++)if(c[i])if(Find(u[i])==Find(v[i]))printf("No\n"),exit(0);//Á½¸ö¶àÌõÂ·¾¶ÔÚÍ¬Ò»¸öÁªÍ¨¿é 
	int sum=0;
	for(int i=1;i<=Q;i++)if(c[i])sum++;
	if(sum && m<n)printf("No\n"),exit(0);//ÒªÓÐ»· 
	printf("Yes\n");
	return 0;
}
/*
4 4 3
0 1 0
1 2 1
2 3 0

1 2 0
2 3 1
3 4 0

1 2
3 4
*/


Measured memory_bytes: 6716
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <complex>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define vvd std::vector<std::vector<long double> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

ll get_l(ll a, ll b, ll w, ll h){
  int ret=0;
  if(a==0) ret= 2*w+h+b;
  else if(b==h) ret = a;
  else if(a==w) ret = w+h-b;
  else ret=2*w+h-a;
  return ret;
}
int main(int argc, char const *argv[]) {
  ll W, H, N, a, b, c, d;
  std::cin >> W >> H >> N;
  vvl p = vv(0, 2, 0, ll);
  for(ll i=0;i<N;i++) {
    std::cin >> a >> b >> c >> d;
    if((a==0||a==W||b==0||b==H)&&(c==0||c==W||d==0||d==H)){
      p.push_back(vector<ll> {get_l(a, b, W, H), get_l(c, d, W, H)});
    }
  }
  multiset<vector<ll>> mp;
  for(int i=0;i<p.size();i++) {
    if(p[i][0] > p[i][1]) swap(p[i][0], p[i][1]);
    mp.insert(std::vector<ll> {p[i][0], 1, i});
    mp.insert(std::vector<ll> {p[i][1], -1, i});
  }
  deque<ll> task;
  for(auto itr = mp.begin();itr!=mp.end();itr++){
    vector<ll> tmp = *itr;
    if(tmp[1]==1){
      task.push_back(tmp[2]);
    }else{
      ll now = task.back();
      task.pop_back();
      if(now!=tmp[2]){
        std::cout << "NO" << '\n';
        return 0;
      }
    }
  }
  std::cout << "YES" << '\n';
  return 0;
}


Measured memory_bytes: 25392
import java.util.Scanner;

/**
 * @author kawakami
 
*/
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
	       
        int x;
        int y;

       
           
           x = as.nextInt();
           y = as.nextInt();
           
           if(x<y){
               System.out.println(x+" "+y);

              }
            else{
               System.out.println(y+" "+x);

              } 
           
           
           

        while(true){
           
           
           x = as.nextInt();
           y = as.nextInt();
           if(x==0 && y==0){
               break;
  }
           
           
           if(x<y){
        	   
              System.out.println(x+" "+y);

             }
           else{
              System.out.println(y+" "+x);

             } 
       }

	}

}

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

struct Node {
    int key;
    Node *next,*prev;
};

Node *nil;

Node* listsearch(int key){
    Node *cur = nil->next;
    while(cur != nil && cur ->key != key){
        cur = cur -> next;
    }
    return cur;
}

void init(){
    nil = (Node *)malloc(sizeof(Node));
    nil -> prev = nil;
    nil -> next = nil;
}

void printlist(){
    Node *cur = nil -> next;
    int isf = 0;
    while(1){
        if(cur == nil)break;
        if(isf++ > 0)printf(" ");
        printf("%d", cur -> key);
        cur = cur -> next;
    }
    printf("\n");
}

void deleteNode(Node *t){
    if(t == nil) return ;
    t -> prev -> next = t -> next;
    t -> next -> prev = t-> prev;
    free(t);
}

void deleteFirst(){
    deleteNode(nil->next);
}
void deleteLast(){
    deleteNode(nil -> prev);
}

void deleteKey(int key){
    deleteNode(listsearch(key));
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil-> next;
    nil->next->prev = x;
    nil->next = x;
    x ->prev = nil;
}

int main(){
    int key, n , i;
    int size = 0;
    char com[20];
    int np = 0,nd = 0;
    scanf("%d", &n);
    init();
    for(i = 0; i < n;i++){
    scanf("%s%d", com, &key);
    if(com[0] == 'i'){insert(key); np++; size++;}
    else if(com[0] == 'd'){
        if(strlen(com) > 6){
            if(com[6] == 'F') deleteFirst();
            else if(com[6] == 'L')deleteLast();
        } else {
            deleteKey(key); nd++;
        }
        size--;
    }   
    }   

    printlist();
    return 0;

}



Measured memory_bytes: 34452
#include<bits/stdc++.h>
using namespace std;
#define int long long
template <class Q>
void clearQueue(Q & q) {
    q = Q();
}
void solve(){
	int x,k,d;cin>>x>>k>>d;
    if(x>=0){
        int close=x%d;
        int steps=x/d;
        int rem=k-steps;
        if(rem<0){
            cout<<x-(k*d);
        }
        else if(rem==0) cout<<close;
        else{
            if(rem%2==0){
                cout<<close;
            }
            else{
                cout<<abs(close-d);
            }
        }
    }
    else{
        x=abs(x);
        int close=x%d;
        int steps=x/d;
        int rem=k-steps;
        if(rem<0){
            cout<<abs(-x+(k*d));
        }
        else if(rem==0) cout<<close;
        else{
            if(rem%2==0){
                cout<<close;
            }
            else{
                cout<<abs(-close+d);
            }
        }
    }
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3648
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 6)


class UnionFind:
    def __init__(self, size):
        self.size = size
        self.parents = [i for i in range(size)]
        self.ranks = [0 for i in range(size)]

    def ancestor(self, i):
        if self.parents[i] == i:
            return i
        else:
            self.parents[i] = self.ancestor(self.parents[i])
            return self.parents[i]

    def union(self, i, j):
        ip = self.ancestor(i)
        jp = self.ancestor(j)
        if ip == jp:
            return False
        else:
            if self.ranks[ip] > self.ranks[jp]:
                self.parents[jp] = ip
            else:
                self.parents[ip] = jp
                if self.ranks[ip] == self.ranks[jp]:
                    self.ranks[ip] += 1

    def same(self, i, j):
        return self.ancestor(i) == self.ancestor(j)

    def __str__(self):
        parentDict = { }
        for i in range(self.size):
            a = self.ancestor(i)
            if a not in parentDict:
                parentDict[a] = [i]
            else:
                parentDict[a].append(i)
        result = "===UnionFind description===\nSize:" + str(self.size) + "\nGroupCount:" + str(
            len(parentDict)) + "\n\nGroups:\n"
        for k in parentDict.keys():
            elements = ""
            for elem in parentDict[k]:
                elements += " " + str(elem) + ","
            result += "Group-"+str(k)+"(Count:"+str(len(parentDict[k]))+"):["+elements+"]\n"
        return result


def solve(N: int, M: int, p: "List[int]", x: "List[int]", y: "List[int]"):
    U = UnionFind(N)
    for i in range(M):
        U.union(x[i] - 1, y[i] - 1)
    sum = 0
    for i in range(N):
        if p[i] == i + 1 or U.same(p[i] - 1, i):
            sum += 1
    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    x = [int()] * (M)  # type: "List[int]"
    y = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, M, p, x, y)


if __name__ == '__main__':
    main()


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

static void call(int n);

int main(void){

    int input;

    cin >> input;

    call(input);

    return 0;

}

static void call(int n){

  int i;
  int x;

  i = 1;

  do{
    x = i;

    if (x % 3 == 0){
      cout << " " << i;
      continue;
    }

    do{
      if ( x % 10 == 3 ){
          cout << " " << i;
          break;
      }
      x /= 10;
    }while(x);
  }while(++i <= n);

  cout << endl;

}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
  string b; cin>>b;
  if (b=="A") cout << "T";
  if (b=="C") cout << "G";
  if (b=="G") cout << "C";
  if (b=="T") cout << "A";
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  string s;
  cin>>s;
  string res;
  rep(i,s.size()){
    if(s[i]=='B' && res.size()>0){
      res = res.substr(0, res.size()-1);
    }
    else if(s[i]=='0' || s[i]=='1'){
      res += s[i];
    }
  }

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256