akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static int bubble_sort(int[] a, int n) {
        int cnt = 0;
        int flag = 0; // 完了した場所
        while (flag < n - 1) {
            for (int i = n - 2; i >= 0; i--) {
                if (a[i] > a[i + 1]) {
                    int temp = a[i + 1];
                    a[i + 1] = a[i];
                    a[i] = temp;
                    cnt++;
                }

            }
            flag++;
        }
        return cnt;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int ans = bubble_sort(a, n);
        for (int i = 0; i < n; i++) {
            System.out.print(a[i]);
            if (i < n - 1)
                System.out.print(" ");
        }
        System.out.println();
        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 26456
import java.util.Scanner

object Main extends App {
  val scanner = new Scanner(System.in)
  val w = scanner.nextLine()

  def uni: String => Boolean = {
    case s if s.length == 0 => true
    case s => s.forall {
      _ == s.head
    }
  }

  def calcKmp(s: String): Seq[Int] = {
    val kmp = new Array[Int](s.length() + 1)
    var j = -1

    kmp(0) = -1

    for (i <- 0 until s.length()) {
      while (j > -1 && s(j) != s(i))
        j = kmp(j)

      j += 1
      kmp(i + 1) = j
    }

    kmp
  }

  def calcPeriod(s: String): Seq[Int] = {
    val kmp = calcKmp(s: String)
    (1 to s.length(), kmp.tail).zipped.map(_ - _)
  }

  def calcGood(s: String): (Int, Int) = {
    if (uni(s)) return (w.length, 1)
    val p = calcPeriod(s).last
    if (p == s.length || s.length % p != 0) return (1, 1)

    val pattern = (calcPeriod(s).init, calcPeriod(s.reverse).init.reverse, 1 until s.length).zipped.count {
      case (l: Int, r: Int, length: Int) =>
        val rLength = s.length - length
        val leftIsGood = length == l || length % l != 0
        val rightIsGood = rLength == r ||  rLength % r != 0
        leftIsGood && rightIsGood
    }
    (2, pattern)

  }

  val (cut, pattern) = calcGood(w)
  println(cut)
  println(pattern)
}

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

int main(){
    long long N,ans=0;
    cin >> N;
    vector<long long> L(N);
    for(int i=0;i<N;++i) cin >> L[i];
    sort(L.begin(),L.end());
    for(int k=N-1;k>1;--k){
        for(int i=0;i<k-1;++i){
           auto it = upper_bound(L.begin(),L.end(), (L[k]-L[i]));
           int index = it - L.begin();
           if(index > i){
                ans += max(0,k-index);
           }
           else{
               ans += k - i - 1;
           }    
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int n,ans=0; cin >> n;
    vector<int> juel(n);
    vector<int> cost(n);
    rep(i,n) cin >> juel[i];
    rep(j,n) cin >> cost[j];
    rep(p,n){
        if(juel[p]>cost[p]){
            ans += juel[p]-cost[p];
        }
    }
    cout << ans << endl;


    return 0;
}

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

class RollingHash
{
    ulong[] h;
    ulong[] power;
    
    public RollingHash(string s, ulong b)
    {
	int sz = s.Length;
	h = new ulong[sz + 1];
	power = new ulong[sz + 1];
	power[0] = 1;
	for (int i = 0; i < sz; i++)
	{
	    power[i + 1] = power[i] * b;
	    h[i + 1] = h[i] * b + s[i];
	}
    }

    public ulong get(int l, int r)
    {
	return h[r] - power[r - l] * h[l];
    }
}


class Program
{
    static string s;
    static RollingHash rh1;
    static RollingHash rh2;
    
    static bool check(int n)
    {
	int len = s.Length;
	for (int i = 0; i <= len - n; i++)
	{
	    ulong hi1 = rh1.get(i, i+n);
	    ulong hi2 = rh2.get(i, i+n);
	    for (int j = i + n; j <= len - n; j++)
	    {
		if (hi1 == rh1.get(j, j+n) && hi2 == rh2.get(j, j+n))
		{
		    return true;
		}
	    }
	}
	return false;
    }

    public static void Main()
    {
	int n = int.Parse(ReadLine());
	s = ReadLine();
	rh1 = new RollingHash(s, 100000007UL);
	rh2 = new RollingHash(s, 10007UL);

	int l = 0, r = n/2 + 1;
	while (r - l > 1)
	{
	    int m = (l + r) / 2;
	    if(check(m)) l = m;
	    else r = m;
	}

	WriteLine(l);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;

int ball[100010];
bool red[100010];

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

  for(int i=1;i<=N;i++)ball[i] = 1;
  red[1] = true;

  for(int i=0;i<M;i++){
    int x, y;
    cin >> x >> y;

    --ball[x];
    ++ball[y];

    red[y] |= red[x];
    if(ball[x] == 0){
      red[x] = false;
    }
  }

  int res = 0;
  for(int i=0;i<=N;i++){
    if(ball[i] > 0 && red[i]){
      ++res;
    }
  }
  cout << res << endl;
  return 0;
}


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

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

    reverse(S.begin(), S.end());

    vector<string> lib = {"maerd", "remaerd", "esare", "resare"};

    for (int i = 0; i < S.size();)
    {
        bool flag = false;
        for (string l : lib)
        {
            if (S.substr(i, l.size()) == l)
            {
                i += l.size();
                flag = true;
                break;
            }
        }

        if (flag != true)
        {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
}

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

int main()
{

ll int c=0,i,p,j,n;
string s;
cin>>s;
n=s.size();
p=n/2;
if(n%2!=0)
{
    p++;
}
j=0;
for(i=n-1;i>=p;i--)
{
    if(s[i]!=s[j])
    {
        c++;
    }
    j++;
}
cout<<c<<endl;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
long int compare_int(const void *a, const void *b)
{
    return *(long int*)a - *(long int*)b;
}
 
long int binary_search_right(long int list[], long int list_size, long int x){
    long int left, right, mid;
    left = 0;
    right = list_size - 1;
 
    while (left <= right) {
        mid = (left + right)/2;
        if(list[left] < x && x <= list[right] && right - left == 1){
            return left;
        }else if(list[mid] < x){
            left = mid;
        }
        else{
            right = mid;
        }
    }
    while(1){
        printf("error");
    }
}
 
long int binary_search_left(long int list[], long int list_size, long int x){
    long int left, right, mid;
    left = 0;
    right = list_size - 1;
 
    while (left <= right) {
        mid = (left + right)/2;
        if(list[left] <= x && x < list[right]&& right - left == 1){
            return right;
        }else if(list[mid] <= x){
            left = mid;
        }
        else{
            right = mid;
        }
    }
    while(1){
        printf("error");
    }
}
 
int main(void){
    long int n, i;
    scanf("%d", &n);
    long int a[100001], b[100001], c[100001];
    for(i = 0; i < n; i++){scanf("%ld", &a[i]);}
    for(i = 0; i < n; i++){scanf("%ld", &b[i]);}
    for(i = 0; i < n; i++){scanf("%ld", &c[i]);}
 
    qsort(a, n, sizeof(long int), compare_int);
    qsort(c, n, sizeof(long int), compare_int);
 
    long int a_b, b_c, k;
    long int ans = 0;
    if(n == 1){
        if(a[0] < b[0] && b[0] < c[0]){
            printf("1\n");
            return 0;
        }else{
            printf("0\n");
            return 0;
        }
    }
 
    for(i = 0; i < n; i++){
        if(b[i] > a[n - 1]){
            a_b = n;
        }else if(b[i] <= a[0]){
            a_b = 0;
        }else{
            a_b = binary_search_right(a, n, b[i]) + 1;//(条件を満たす最大の配置番号＋１)通りがある
        }
 
        if(b[i] >= c[n - 1]){
            b_c = 0;
        }else if(b[i] < c[0]){
            b_c = n;
        }else{
            b_c = n - binary_search_left(c, n, b[i]);
        }
        ans += a_b * b_c;
    }
    printf("%ld\n", ans);
    return 0;
}

Measured memory_bytes: 4860
#include <iostream>

using namespace std;

struct Card {
    char suit, value;
};

void outputCard(Card arr[], int n) {
    for (int i = 0; i < n; i++)
        if (i == n - 1) {
            cout << arr[i].suit << arr[i].value << endl;
        } else {
            cout << arr[i].suit << arr[i].value << " ";
        }
}

void bubble_sort(struct Card A[], int N) {
    int flag = 1;
    for (int i = 0; flag; i++) {
        flag = 0;
        for (int j = N - 1; j > i; j--) {
            if (A[j].value < A[j - 1].value) {
                Card temp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = temp;
                flag = 1;
            }
        }
    }
    outputCard(A, N);
    cout << "Stable" << endl;
}

void selection_sort(struct Card A[], int N) {
    int minIndex;
    for (int i = 0; i < N; i++) {
        minIndex = i;
        for (int j = i + 1; j < N; j++) {
            if (A[j].value < A[minIndex].value) {
                minIndex = j;
            }
        }
        if (minIndex != i) {
            Card temp = A[i];
            A[i] = A[minIndex];
            A[minIndex] = temp;
        }
    }
    outputCard(A, N);
}

bool isStable(Card c1[], Card c2[], int N) {
    for (int i = 0; i < N; i++)
        if (c1[i].suit != c2[i].suit) return false;

    return true;
}

int main() {
    int n;
    Card c1[100], c2[100];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> c1[i].suit >> c1[i].value;
    for (int i = 0; i < n; i++)
        c2[i] = c1[i];

    bubble_sort(c1, n);
    selection_sort(c2, n);
    bool res = isStable(c1, c2, n);
    if (res) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include<vector>
#include<set>
using namespace std;

struct Fish {int left, front, top, right, back, bottom;};

int main() {
    int N, K;
    cin >> N >> K;
    vector<Fish> fish(N);
    for(auto& f: fish) cin >> f.left >> f.front >> f.top >> f.right >> f.back >> f.bottom;

    set<long long int > tx, ty, tz;
    for(const auto& f: fish) {
        tx.insert(f.left);
        tx.insert(f.right);
        ty.insert(f.front);
        ty.insert(f.back);
        tz.insert(f.top);
        tz.insert(f.bottom);
    }
    vector<long long int> x(tx.begin(), tx.end()), y(ty.begin(), ty.end()), z(tz.begin(), tz.end());

    long long int answer = 0;
    for(int i = 1; i < x.size(); ++i) for(int j = 1; j < y.size(); ++j) for(int k = 1; k < z.size(); ++k) {
        int count = 0;
        for(const auto& f: fish)
            if((f.left < x[i] && x[i] <= f.right) && (f.front < y[j] && y[j] <= f.back) && (f.top < z[k] && z[k] <= f.bottom))
                ++count;
        if(count >= K) answer += (x[i] - x[i - 1]) * (y[j] - y[j - 1]) * (z[k] - z[k - 1]);
    }
    cout << answer << endl;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
long gcd(long a,long b){
  if(a==0){
    return b;
  }
 
  return gcd(b%a,a);
  
}
int main() {
  long A,B;
  long C,D;
  cin >> A>>B>>C>>D;
 
    
 long l=C*D/gcd(C,D);
  long ans=B-B/C-B/D+B/l-((A-1)-(A-1)/C-(A-1)/D+(A-1)/l);
  cout<<ans<<endl;
 

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back


void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


string s;
int ans;

signed main(){
  cin>>s;

  int i=0,j=s.size()-1;
  while(i<=j){
    if(s[i]==s[j]){
      i++;
      j--;
      continue;
    }
    if(s[i]=='x'){
      ans++;
      i++;
      continue;
    }
    if(s[j]=='x'){
      ans++;
      j--;
      continue;
    }
    else{
      ans=-1;
      break;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    
    long long n;
    cin >> n;
    
    if(n&1){
        cout << 0 << endl;
        return 0;
    }
    
    long long res = 0;
    long long deno = 10;
    while(deno <= n){
        res += n/(deno);
        deno *= 5;
        //idx += 1;
    }
    
    cout << res << endl;
    
    
    return 0;
    
}

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

int par[MAX_N];
int union_rank[MAX_N];

void init(int n){  //初期化
    for(int i = 0; i < n; i++){
        par[i] = i;
        union_rank[i] = 0;
    }
}

int find(int x){ //木の根を調べる
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y){ //要素をくっつける
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(union_rank[x] < union_rank[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(union_rank[x] == union_rank[y]) union_rank[x]++;
    }
}

bool same(int x, int y){ //同じ集団に属するかどうか
    return find(x) == find(y);
}

int main(){
    int n, m; cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    init(n);
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        unite(x, y);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(same(a[i], i+1)){
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main()
{
	int n, k;
	cin >> n >> k;

	int a = 0;
	for( int i = 0; i < n; i++ ) {
		if( i == 0 ) {
			a = k;
		}
		else {
			a = a * ( k - 1 );
		}
	}

	cout << a << endl;
	return 0;
}

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

namespace Polish_Notation
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(string.Join("",Console.ReadLine().OrderBy(c=>c))=="abc"?"Yes":"No");
        }
    }
}

Measured memory_bytes: 13268
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] x = new double[n];
		double[] y = new double[n];
		for (int i = 0; i < n; ++i) {
			x[i] = sc.nextDouble();
			y[i] = sc.nextDouble();
		}
		for (int i = 0; i < n; ++i) {
			double[] deg = new double[n - 1];
			int cnt = 0;
			for (int j = 0; j < n; ++j) {
				if (i == j)
					continue;
				deg[cnt++] = (Math.atan2(y[j] - y[i], x[j] - x[i]));
			}
			Arrays.sort(deg);
			double ans = 0;
			for (int j = 0; j < n - 2; ++j) {
				ans = Math.max(ans, deg[(j + 1) % (n - 1)] - deg[j]);
			}
			ans = Math.max(ans, Math.PI * 2 + deg[0] - deg[n - 2]);
			ans = ans - Math.PI;
			if (ans <= 0)
				System.out.println(0);
			else
				System.out.println(String.format("%.20f", ans / (2 * Math.PI)));
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 25012
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int q = sc.nextInt();
        for(int i=0; i<q; i++){
            String order = sc.next();
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(order.equals("replace")) {
                String p = sc.next();
                str = str.substring(0, a) + p + str.substring(b+1);
            }else if(order.equals("reverse")){
                StringBuffer sb = new StringBuffer(str.substring(a, b+1));
                str = str.substring(0, a) + (sb.reverse()).toString() + str.substring(b+1);
            }else{
                System.out.println(str.substring(a, b+1));
            }

        }
    }
}


Measured memory_bytes: 29680
n, k = map(int, input().split())

S = input()
para = [0]
for i, s in enumerate(S):
    if i == 0:
        para.append(1)
    else:
        if S[i] == S[i-1]:
            para[-1] += 1
        else:
            para.append(1+para[-1])
i = 0
if (S[-1] == '0'):
    para.append(para[-1])

#print(para)
tmpmax = 0

if S[0] == '1':
    if i + 2*k + 1 >= len(para) - 1:
        print(n)
    else:
        while i + 2*k + 1 <= len(para) - 1:
            j = i + 2*k + 1
            tmpmax = max(tmpmax, para[j] - para[i])
            #if para[j] - para[i-1] > tmpmax:
            #    tmpmax = para[j] - para[i]

            i += 2
        print(tmpmax)
else:
    if i + 2*k >= len(para) - 1:
        print(n)
    else:
        while i + 2*k <= len(para) - 1:
            j = i + 2*k
            if i == 0:
                tmpmax = max(tmpmax, para[j] - para[i])
                #if para[j] - para[i] > tmpmax:
                #    tmpmax = para[j] - para[i]
            else:
                tmpmax = max(tmpmax, para[j] - para[i-1])
                #if para[j] - para[i-1] > tmpmax:
                #    tmpmax = para[j] - para[i-1]

            i += 2
        print(tmpmax)



Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string a,b,c,count;
  int a1,b1,c1,a2=0,b2=0,c2=0;
  cin>>a>>b>>c;
  a1=a.length();
  b1=b.length();
  c1=c.length();
  count=a[a2];
  a2++;
  for(int i=0;i<a1+b1+c1;i++){
    if(count=="a"){
      count=a[a2];
      a2++;
      if(a2==a1+1){
	cout<<"A"<<"\n";
	break;
      }
    }else if(count=="b"){
      count=b[b2];
      b2++;
      if(b2==b1+1){
	cout<<"B"<<"\n";
	break;
      }
    }else if(count=="c"){
      count=c[c2];
      c2++;
      if(c2==c1+1){
	cout<<"C"<<"\n";
	break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] input = In.ReadToEnd().Split(new[] { " ", "\n", "\r" },
        StringSplitOptions.RemoveEmptyEntries);

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

#region Library

static class Extentions
{
}

#endregion

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO());
        Out.Flush();
    }

    static void Solve(IO io)
    {
        var n = io.I;
        var k = io.I;
        var x = io.I;
        var y = io.I;

        io.Write(x * Min(n, k) + y * Max(0, n - k));
    }
}

Measured memory_bytes: 13268
/* ex5_4 "ATCoder"
    dada__      */
#include<stdio.h>
#include<string.h>
 
int main(void){
    char *ptr, *ptr2, sequence1[11], part_seq[11]="",longest_seq[11]="";
    scanf("%s", sequence1);//文字列の入力
    ptr=sequence1; //ptrに入力文字列の先頭アドレスを代入
    ptr2=part_seq; //ptr2に部分文字列の先頭アドレスを代入
 
    while(*ptr){
        while(*ptr){
            //文字列に'A','C','G','T'がでるまでptrを移動 
            if(*ptr!='A'&&*ptr!='C'&&*ptr!='G'&&*ptr!='T') ptr++;
            else break;
        }
 
        while(*ptr){
            //文字列が'A','C','G','T'の間は部分文字列としてコピー
            if(*ptr=='A'||*ptr=='C'||*ptr=='G'||*ptr=='T'){
                *ptr2++ = *ptr++;
            }else{//'A','C','G','T'以外で部分文字列終了
                *ptr2='\0';
                break;
            }
        }
        //最長部分文字列の更新
        if(strlen(part_seq)>strlen(longest_seq)) strcpy(longest_seq,part_seq);
        //ptr2を部分文字列の先頭に移動
        ptr2-=strlen(part_seq);
    }
    //最長の部分文字列の長さを出力
    printf("%d\n", strlen(longest_seq));
    return 0;
 
}

Measured memory_bytes: 1700
#include<iostream>

using namespace std;

int main(){
	int N;
	string S;
	int K;
	cin >> N;
	cin >> S;
	cin >> K;
	char c = S[K-1];
	for(int i=0;i<N;i++){
		if(S[i] != c){
			S[i] = '*';
		}
	}
	cout << S;
}

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

string s;

int main()
{
    cin>>s;

   sort (s.begin() , s.end() ) ;
   

   if ( (s[0] == s[1]) && (s[2] == s[3]) && (s[1] != s[2]))
      cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

   return 0;
    
}

Measured memory_bytes: 256
# AtCoder Beginner Contest 150
# C - Count Order
# https://atcoder.jp/contests/abc150/tasks/abc150_c

from itertools import permutations

N = int(input())
P = tuple(i-1 for i in map(int, input().split()))
Q = tuple(i-1 for i in map(int, input().split()))

F = list(permutations(range(N)))

print(abs(F.index(P) - F.index(Q)))


Measured memory_bytes: 8052
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define fo(i,a,n) for (i = a; i <= n; i++)
#define F first
#define S second
#define pii pair<int,int>
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back
#define pf push_front    
#define PB pop_back
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;


void solve(){
    int a, b;
    cin>>a>>b;
    for(int i = 1; i <= 1e5; i++){
        if(i*8 / 100 == a && i*10 / 100 == b){
            cout<<i;
            return ;
        }
    }
    cout<<"-1";
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


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

int main(){
	string a,b,c;
	string d,e,f;
	cin>>a>>b>>c;
	d=*(a.begin());
	e=*(b.begin());
	f=*(c.begin());
	cout<<d<<e<<f;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

struct key
{
	int cost;
	unsigned int unlock;
};
key keys[1000];
int dp[1 << 12];

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);

	int tpown = 1 << n;

	memset(dp, 0x7F, sizeof(int) * tpown);

	for (int i = 0; i < m; ++i)
	{
		int b;
		scanf("%d %d", &keys[i].cost, &b);
		for (int j = 0; j < b; ++j)
		{
			int c;
			scanf("%d", &c);
			keys[i].unlock |= (1 << (c - 1));
		}
	}

	dp[0] = 0;
	for (int i = 0; i < m; ++i)
	{
		for (int j = 0; j < tpown; ++j)
		{
			dp[j | keys[i].unlock] = std::min(dp[j | keys[i].unlock], dp[j] + keys[i].cost);
		}
	}

	if (dp[tpown - 1] == 0x7F7F7F7F)
	{
		puts("-1");
	}
	else
	{
		printf("%d\n", dp[tpown - 1]);
	}
	return 0;
}


Measured memory_bytes: 128
H, W = map(int, input().split())
L = []
for i in range(H):
    L.append(list(input()))
dH = []
for i in range(H):
    if L[i].count('.') == W:
        dH.append(i)
dW = []
for i in range(W):
    flag = True
    for j in range(H):
        if L[j][i] == '#':
            flag = False
            break
    if flag:
        dW.append(i)
for i in range(H):
    if i in dH:
        continue
    ans = []
    for j in range(W):
        if not j in dW:
            ans.append(L[i][j])
    print(''.join(ans))

Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rem(i, s, n) for (int i = (s); i >= (n); --i)
using ll = long long;
const int MOD = 1e9 + 7;

int main(){
    char c; cin >> c;

    cout << (char)(c + 1) << endl;

    return 0;
}

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


int main()
{
   int i,j,n,a,b,c,t,ret=0;
   cin>>a>>b>>c;
   for(i=a;i<=b;i++)
   {
       if(i%c==0)
        ret++;
   }
   cout<<ret<<"\n";

    return 0;

}


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

sys.setrecursionlimit(300000)

class BinaryIndexedTree(object):

    def __init__(self, n):
        # index is 1-based so vals[0] never be used
        self.n = n
        self.vals = [0] * (n + 1)

    def add(self, i, v):
        while i <= self.n:
            self.vals[i] += v
            i += i & -i

    def sum(self, i):
        ret = 0
        while i > 0:
            ret += self.vals[i]
            i -= i & -i
        return ret

    def sum_range(self, l, r):
        # l and r are 1-based index and inclusive
        return self.sum(r) - self.sum(l - 1)


def solve(N, S, Q, queries):
    trees = []
    for i in range(26):
        trees.append(BinaryIndexedTree(N))

    s = []
    for i, c in enumerate(S):
        c_idx = ord(c) - ord('a')
        if 'a' <= c <= 'z':
            trees[c_idx].add(i + 1, 1)
        s.append(c)

    for q in queries:
        if q[0] == '1':
            i, c = int(q[1]), q[2]
            p = s[i - 1]
            s[i - 1] = c
            trees[ord(p) - ord('a')].add(i, -1)
            trees[ord(c) - ord('a')].add(i, 1)
        if q[0] == '2':
            l, r = int(q[1]), int(q[2])
            ret = 0
            for tree in trees:
                cnt = tree.sum_range(l, r)
                if cnt:
                    ret += 1
            print(ret)
        #pprint(get_range_sum(1, 5, bit))
        #print(s)
        #print()

    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))
    S = str(next(tokens))
    Q = int(next(tokens))
    q = []
    for i in range(Q):
        q.append(list(map(str, input().split())))
    solve(N, S, Q, q)

if __name__ == '__main__':
    main()


Measured memory_bytes: 171872
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=Math.ceil(e/2),n=9999999999999,i=1;i<=r;i++){for(var o=i,s=e-i,u=0;o>0;)u+=o%10,o=Math.floor(o/10);for(;s>0;)u+=s%10,s=Math.floor(s/10);n>u&&(n=u)}console.log(n)}}]);

Measured memory_bytes: 7628
from collections import Counter
N = int(input())
L = list(map(int, input().split()))
c = Counter(L)
# print(c)
# 先にxを選んでおく！
ans = 0
m = max(L) + 1
for i in range(m):
    ans = max(ans, c[i - 1] + c[i] + c[i + 1])

print(ans)


Measured memory_bytes: 14564
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

void solve() {
	int N; cin >> N;
	ll ans = 1e18;
	for (int i = 1; i*i <= N; i++) {
		if (N%i != 0)continue;
		ans = min(ans, i + N / i-2);
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}

Measured memory_bytes: 256
/*
                           \\\|///
                         \\  - -  //
                          (  @ @  )
O-----------------------oOOo-(_)-oOOo--------------------O
| CPP-file           *******                 IOI         |
|                by  *Jacob*	             IZhO        |
|                    *******                 BOI         |
|   <I_am_Champion>              Oooo        APIO        |
O------------------------oooO---(   )--------------------O
                        (   )    ) /
                        \  (    (_/
                         \_)
SITE: USACO
ID: allakov1
TASK:
LANG: C++
*/
#include<bits/stdc++.h>
//#include<conio.h>
#define pb(a) push_back(a)
#define pp() pop_back()
#define ff first
#define ss second
#define inf 1000000000
#define pii pair<int,int>
#define pll pair<long long,long long>
#define ll  long long
using namespace std;
const int N=INT_MAX;
ll a,b,d,n,j,i,k,l,m;
char c;
int main()
{
//	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>a>>c>>b;
	if(c=='+') cout<<a+b;
	else cout<<a-b;
}

Measured memory_bytes: 256
import java.util.*;
        import java.lang.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[] V = new int[N];
        int[] C = new int[N];

        int ans=0;

        for(int n=0; n<N; n++) V[n] = sc.nextInt();
        for(int n=0; n<N; n++) C[n] = sc.nextInt();
        for(int n=0; n<N; n++) ans += Math.max(0, V[n]-C[n]);

        System.out.println(ans);

    }
}

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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(b, n * a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
//prototype
int main(void);

int main(void){

  int ni = 0, mi = 0;
  int n, m;
  int matrix_value;
  int vector_value;
  int count = 1;

  scanf("%d %d", &n, &m);

  int Matrix_A[n][m];
  int Vector_b[m][1];
  int Product_Arrays[n][1];

  //Initialize Product_Arrays
  for (ni = 0; ni < n ; ni++) {
    Product_Arrays[ni][0] = 0;
  }

  //Matrix_A processing
  ni = 0;
  while(1){
    scanf("%d", &matrix_value);
    Matrix_A[ni][mi] = matrix_value;

    mi++;

    if (mi >= m) {
      ni++;
      mi = 0;
    }

    count++;

    if(count > (m * n)){
      break;
    }
  }

  //Vector_b processing
  while(1){
    scanf("%d", &vector_value);
    Vector_b[mi][0] = vector_value;

    mi++;

    if (mi >= m) {
      break;
    }
  }


  //product of arrays
  for (ni = 0; ni < n; ni++) {
    for (mi = 0; mi < m; mi++) {
      Product_Arrays[0][ni] += Matrix_A[ni][mi] * Vector_b[mi][0];
    }
  }

  //disp Product_Arrays
  for (ni = 0; ni < n; ni++) {
    printf("%d\n", Product_Arrays[0][ni]);
  }

  return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>

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

using namespace std;

char dan[22][4][4];
char drop[5][2][4][4];

bool check(int d, int n, int sx, int sy){
//	cout << "check " << d << " " << n << " " << sx << " " << sy << endl;
	rep(i,2) for(int x=1; x<=2; x++) for(int y=1; y<=2; y++){
		if( dan[d+i][x+sx][y+sy] == '#' && drop[n][i][x][y] == '#' ){
			return false;
		}
	}
	return true;
}

int merge(int d, int n, int sx, int sy){
	int ret = 0;
	rep(i,2) for(int x=1; x<=2; x++) for(int y=1; y<=2; y++){
		if( dan[d+i][x+sx][y+sy] == '.' ){
			dan[d+i][x+sx][y+sy] = drop[n][i][x][y];
		}
	}
	rep(i,2){
		if( d+i < 2 ) continue;
		int cnt = 0;
		rep(x,4) rep(y,4){
			if( dan[d+i][x][y] == '#' ) cnt++;
		}
		if( cnt == 16 ){
			for(int j=d+i; j<20; j++) rep(x,4) rep(y,4){
				dan[j][x][y] = dan[j+1][x][y];
			}
			d--;
			ret++;
		}
	}
	return ret;
}

int solve(int n){
	if( n >= 3 ) return 0;
	int ret = 0, ans=0;
	char _dan[22][4][4];
	rep(sx,3) rep(sy,3){
		rep(i,22) rep(y,4) rep(x,4) _dan[i][y][x] = dan[i][y][x];
		bool f = false;
		for(int d=20; d>=0; d--){
			if( !check(d,n,sx-1,sy-1) ){
				if( d > 18 ){
					f = true;
					break;
				}
				ans = merge(d+1,n,sx-1,sy-1);
				break;
			}
		}
		if( f ) continue;
		ret = max( ret, ans+solve(n+1) );
		rep(i,22) rep(y,4) rep(x,4) dan[i][y][x] = _dan[i][y][x];
	}
	return ret;
}

int main(){
	int H, N;
	while( cin >>H >>N, N|H ){
		fill( (char*)dan[0], (char*)dan[22], '#' );
		fill( (char*)drop[0], (char*)drop[5], '.' );
		rep(i,20) rep(y,2) rep(x,2) dan[i+2][y+1][x+1] = '.';
		rep(i,H) rep(j,2) rep(k,2){
			cin >> dan[i+2][j+1][k+1];
		}
		rep(n,N) rep(i,2) rep(j,2) rep(k,2){
			cin >> drop[n][i][j+1][k+1];
		}
		cout << solve(0) << endl;
	}
	return 0;
}

Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int h[22];
	scanf("%d ",&n);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);int finalhe=0;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(h[i]>=finalhe) ans++;
		finalhe=max(finalhe,h[i]);
		
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
import java.util.Scanner;

public class Main {

    static class D {
        int x;
        int y;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a + b + c >= 22) {
            System.out.println("bust");
        } else {
            System.out.println("win");
        }
    }
}


Measured memory_bytes: 23636
n = int(input())
rects = list(map(int, input().split()))
rects.append(-1)
stack = []
ans = 0

for ind, rect in enumerate(rects):
#  print(stack)
  if not stack:
    stack.append((rect, ind))
  elif stack[-1][0] < rect:
    stack.append((rect, ind))
  elif stack[-1][0] == rect:
    continue
  else:
    while stack and stack[-1][0] > rect:
      prect, pind = stack.pop()
      ans = max(ans, prect * (ind - pind))
    stack.append((rect, pind))


print(ans)


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

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int taka = c/b;
    if(c%b > 0){
        taka++;
    }
    int ao = a/d;
    if(a%d > 0){
        ao++;
    }
    if(taka <= ao){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
import sys
x, y = map(int, input().split())

if (x + y) % 3 != 0:
    print(0)
    sys.exit()

mod = 10**9 + 7
n = (x+y) // 3
a = min(
    (2 * x - y) // 3, (2 * y - x) // 3
)


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


N = max(x, y)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

ans = cmb(n, a, mod)
print(ans)


Measured memory_bytes: 123916
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;
import java.util.Random;
import java.util.Map;
import java.util.HashMap;

class Main{
        public static void main(String args[]){
                Scanner sc = new Scanner(System.in);
                int a = sc.nextInt();
                int b = sc.nextInt();
                String s = sc.next();
                HashMap<Character,Integer> m = new HashMap<Character,Integer>();
                boolean afterHihun = false;

                m.put('h',0);
                m.put('a',0);
                m.put('b',0);

                for(int i = 0; i < a + b + 1; i ++){
                        if(s.charAt(i) == '-'){
                                m.put('h',m.get('h')+1);
                                afterHihun = true;
                        }else if(!afterHihun){
                                m.put('a',m.get('a')+1);
                        }else{
                                m.put('b',m.get('b')+1);
                        }
                }
                if(m.get('h') == 1
                && m.get('a') == a
                && m.get('b') == b){
                        System.out.println("Yes");
                }else{
                        System.out.println("No");
                }
        }
}


Measured memory_bytes: 21844
n, k, q = gets.split.map(&:to_i)
a = q.times.map { gets.to_i }
points = Array.new(n + 1, k - q)

q.times do |i|
  points[a[i]] += 1
end

puts points[1..n].map { |v| v > 0 ? 'Yes' : 'No' }


Measured memory_bytes: 11772
// 全探索  
#include <iostream>
#include <numeric>

using namespace std;

int main(){
    int K;
    int64_t ans = 0;

    cin >> K;

    for(int a = 1; a <= K; a++){
        for(int b = 1; b <= K; b++){
            for(int c = 1; c <= K; c++){
                // 最大公約数なので2回に分けても大丈夫? 
                int tmp = gcd(a, b);
                ans += gcd(tmp, c);
            }
        }
    }

    cout << ans;

    return 0;
}

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

using namespace std;

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

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

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

int n;
int index[10000], p[10000], q[10000], r[10000];
int PPP, Q, R, C;
vector<int> vi;

int main(){
	while (cin >> n&&n){
		REP(i, n)cin >> index[i] >> p[i] >> q[i] >> r[i];
		cin >> PPP >> Q >> R >> C;
		REP(i, n){
			bool f = 1;
			int cal = 4 * (p[i] + r[i]) + 9 * q[i];
			if (cal > C)f = 0;
			if (p[i] > PPP)f = 0;
			if (q[i] > Q)f = 0;
			if (r[i] > R)f = 0;
			if (f)vi.push_back(index[i]);
		}
		if (vi.empty())cout << "NA" << endl;
		else{
			REP(i, vi.size()){
				cout << vi[i] << endl;
			}
		}
		vi.clear();
	}
}

Measured memory_bytes: 1260
x = input()

sum_1 = 0
for item in x:
  sum_1 += int(item)

sum_1 = str(sum_1)
sum_2 = 0
for item in sum_1:
  sum_2 += int(item)

if sum_2 % 9 == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9344
/*
NOTE :
*min_element(.begin(),.end())
*max_element(.begin(),.end())
stack push pop top
queue push pop front
priority_queue<> pq
 push()  pop() size()  top()
map<>
 find() begin() end() insert(map<>::value_type())
pair<>
sort(.begin(), .end())
sort(arr, arr+N)
sort(a, a+N, greater<int>())
binary_search(vc.begin(), vc.end(), x)  //binary_search???true, false?????????
vector<int>::iterator lit = lower_bound(vc.begin(), vc.end(), x);
  lower_bound?????????????????????"??\???"????????????????????????????????????????????¬???????????????
vector<int>::iterator uit = upper_bound(vc.begin(), vc.end(), x);
  upper_bound????????????????????????"?¶???????"?????????????????????????????????????????¬???????????????
*/
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <valarray>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define MAX 100
#define INF 1<<20
#define LLINF 10e12 // 1<<31 // 2^31
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,a,n) for(int i=(a);i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique(ALL((o))), (o).end());

using namespace std;
typedef long long ll;
typedef valarray<int> array_t;
/////

/////
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // FROM HERE
  double x = 0, y = 0;
  int a, b, r = 0;
  while(scanf("%d,%d",&a,&b),a|b)
  {
      y += a * cos(1.0*r*M_PI/180);
      x += a * sin(1.0*r*M_PI/180);
      r += b;
  }
  printf("%d\n%d\n",(int)x,(int)y);
  return 0;
}

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

int main() {
	ll n, x, m; cin >> n >> x >> m;
	vector<ll> cnt;
	ll rem = x;
	ll tmp = m;
	while (tmp--) {
		cnt.push_back(rem);
		rem = (ll)pow(rem, 2) % m;
		if (find(cnt.begin(), cnt.end(), rem) != cnt.end())
			break ;
	}
	ll mae = distance(cnt.begin(), find(cnt.begin(), cnt.end(), rem));
	ll maeSUM = accumulate(cnt.begin(), cnt.begin() + mae, 0LL);
	ll loop = cnt.size() - mae;
	ll loopSUM = accumulate(cnt.begin() + mae, cnt.end(), 0LL);
	ll res = 0;
	if (n <= cnt.size())
		res += accumulate(cnt.begin(), cnt.begin() + n, 0LL);
	else {
		res += maeSUM;
		n -= mae;
		ll div = n / loop;
		ll mod = n % loop;
		res += loopSUM * div;
		res += accumulate(cnt.begin() + mae, cnt.begin() + mae + mod, 0LL);
	}
	cout << res << '\n';
    return 0;
}


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

int a[8];
inline vector<int> cmp(vector<int> b,vector<int> c){
	int bb=0,cc=0;
	rep(i,8) bb+=max(a[i]-b[i],0);
	rep(i,8) cc+=max(a[i]-c[i],0);
	if(bb < cc) return b;
	if(cc < bb) return c;
	if(b < c) return b;
	if(c < b) return c;
	return b;
}

int main(void){
	while(1){
		rep(i,8) cin >> a[i];
		if(cin.eof()) break;
  		vector<int> s={4,1,4,1,2,1,2,1};
  		vector<int> ans={4,1,4,1,2,1,2,1};
  		rep(loop,8){
  			rotate(s.begin(),s.begin()+1,s.end());
  			ans=cmp(s,ans);
  		}
  		rep(i,8) cout << (i?" ":"") << ans[i];
  		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
n = int(input())
h = list(map(int, input().split()))

for i in range(0,n-1):
    l = h[-(2+i)]
    r = h[-(1+i)]
    if l - r == 1:
        h[-(2+i)] = l-1
    elif l - r > 1 :
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 14396
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a,b;
        a= sc.nextInt();
        b= sc.nextInt();
        if(a>b){
            System.out.println("a > b");
        }
        else if(a<b){
            System.out.println("a < b");
        }
        else{
            System.out.println("a == b");
        }
    }
        }



Measured memory_bytes: 26120
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
  int n;
  cin >>  n;//nは10の5乗数
  // vector<vector<vector<long>>> f(n,vector<vector<long>>(5,vector<long>(2,0)));
  vector<vector<long>> f(n, vector<long>(10, 0));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> f[i][j];
    }
  }


  vector<vector<long>> p(n, vector<long>(11, 0));

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


  long ans = -1000000000;
  for (int i = 1; i < (1 << 10); ++i) { //10この集合について全探索
    int cc = 0;
    for ( int k = 0; k < n ; k ++){
      int c = 0;//カウント
      for ( int j = 0; j < 10; j ++) if (( i >> j & 1) && f [ k ][ j ]) c ++;
      cc += p[ k ][ c ];//価値
    }
    if ( ans < cc ) ans = cc ;
  }



  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256