akhauriyash/Code-Regression huggingface dataset:
h,w,m = map(int,input().split())
hw = [list(map(int,input().split())) for _ in range(m)]

hc = [0]*h
wc = [0]*w
d={}
for _h, _w in hw:
    hc[_h-1]+=1
    wc[_w-1]+=1
    d[(_h-1,_w-1)]=1
    
maxh = max(hc)
maxw = max(wc)
    
        
hoge = True
wi = [i for i in range(w) if wc[i]==maxw]
for h in [i for i in range(h) if hc[i]==maxh]:
    for w in wi:
        if (h,w) not in d:
            hoge=False
            break
            
if hoge:
    print(maxh+maxw-1)
else:
    print(maxh+maxw)

Measured memory_bytes: 140340
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

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

    int l;
    long stocks = 1000;

    for (long long i = 1; i*i <= n; i++) {
        if (n % i != 0) continue;
        string s = to_string(n/i);
        if (s.size() < stocks) stocks = s.size();
        
    }

    cout << stocks << endl;

}

Measured memory_bytes: 3768
s = input()
t = input()

min=1000

for i in range(len(s)-len(t)+1):
    sa=0
    ss=s[i:i+len(t)]
    for j in range(len(t)):
        if ss[j]!=t[j]:
            sa+=1
    if sa<min:
        min=sa

print(min)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
#include <cstring>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int x,y,g;
    cin>>x;
    cin>>y;
    g=y;
    for (int i=1;i<x;i++)
    {
        cin>>y;
        g=__gcd(g,y);
    }
    cout<<g<<endl;
    return 0;
}


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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define endl "\n"

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 N, M, quere, element; vector<deque<_i64>> lane;
        vector<_i64> car; size_t index;
        cin >> N >> M; lane.resize(N); car.resize(N, 0);
        _rep(i, M) {
            cin >> quere >> element;
            switch(quere) {
                case 0:
                    cout << lane[element - 1][0] << endl;
                    lane[element - 1].pop_front(); --car[element - 1];
                    break;
                case 1:
                    index = distance(car.begin(), min_element(_all(car)));
                    lane[index].push_back(element); ++car[index];
                    break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3232
N=int(input())

S=input()

ans=[]
tmp=[1,S]
ans.append(tmp)
count=1

for i in range(1,N):
    S=input()
    for j in range(count):
        if ans[j][1]==S:
            ans[j][0]+=1
            break
    else:
        tmp=[1,S]
        ans.append(tmp)
        count+=1

M=int(input())

for i in range(M):
    S=input()
    for j in range(count):
        if ans[j][1]==S:
            ans[j][0]-=1
            break

ans.sort()
ans.reverse()

if ans[0][0]<0:
    print(0)
else:
    print(ans[0][0])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pair<int,pii>,vector<pair<int,pii> >,greater<pair<int,pii> > >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int a,b,c;cin>>a>>b>>c;
    if(a==b and a!=c)
        cout<<"Yes";
    else if(b==c and a!=b)
        cout<<"Yes";
    else if(a==c and a!=b)
        cout<<"Yes"<<endl;
    else
        cout<<"No";
}

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

using namespace std;

using Vec = vector<int>;
using Mat = vector<Vec>;

int simulate(int v, int dir, Vec& d, Mat adj)
{
    int cnt = 1;
    while (true) {
        int next = adj[v][dir];
        if (next == -1) break;
        
        for (int i = 0; i < 4; i++) {
            if (adj[v][i] != -1) {
                adj[adj[v][i]][(i + 2) % 4] = adj[v][(i + 2) % 4];
            }
        }
        
        v = next;
        dir = d[v];
        cnt += 1;
    }    
    return cnt;
}

int main()
{
    int N;
    cin >> N;
    Vec x(N), y(N), d(N);
    const string dv = "<^>v";
    for (int i = 0; i < N; i++) {
        char ch;
        cin >> x[i] >> y[i] >> ch;
        d[i] = dv.find(ch);
    }

    Mat adj(N, vector<int>(4, -1));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) continue;
            if (x[i] == x[j]) {
                if (y[i] > y[j] && (adj[i][1] == -1 || y[adj[i][1]] < y[j])) {
                    adj[i][1] = j;
                }
                if (y[i] < y[j] && (adj[i][3] == -1 || y[adj[i][3]] > y[j])) {
                    adj[i][3] = j;
                }
            }
            if (y[i] == y[j]) {
                if (x[i] > x[j] && (adj[i][0] == -1 || x[adj[i][0]] < x[j])) {
                    adj[i][0] = j;
                }
                if (x[i] < x[j] && (adj[i][2] == -1 || x[adj[i][2]] > x[j])) {
                    adj[i][2] = j;
                }
            }
        }
    }

    int res = 0;
    for (int i = 0; i < N; i++) {
        res = max(res, simulate(i, d[i], d, adj));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3460
import java.io.*;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    long k = sc.nextLong();
    Long[] a = new Long[n];
    Long[] f = new Long[n];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }
    for (int i = 0; i < n; i++) {
      f[i] = sc.nextLong();
    }
    Arrays.sort(a, Comparator.naturalOrder());
    Arrays.sort(f, Comparator.reverseOrder());

    long ok = 1;
    while (!canFinish(ok, n, k, a, f)) ok *= 2;
    long ng = ok / 2 - 1;
    while (ok - ng > 1) {
      long mid = (ok + ng) / 2;
      if (canFinish(mid, n, k, a, f)) ok = mid;
      else ng = mid;
    }

    os.println(ok);
  }

  private static boolean canFinish(long time, int n, long k, Long[] a, Long[] f) {

    for (int i = 0; i < n; i++) {
      long c = time / f[i];
      k -= Math.max(a[i] - c, 0);
    }
    return k >= 0;
  }

  private static class Scanner {

    private final InputStream is;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    Scanner(InputStream is) {
      this.is = is;
    }

    private boolean hasNextByte() {
      if (ptr < buflen) {
        return true;
      } else {
        ptr = 0;
        try {
          buflen = is.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (buflen <= 0) {
          return false;
        }
      }
      return true;
    }

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

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

    public boolean hasNext() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
      return hasNextByte();
    }

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

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

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

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


Measured memory_bytes: 42680
day = ["Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"]
month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
while True:
	m, d = map(int, raw_input().split())
	if m == d == 0: break
	print day[(sum(month[0:m-1]) + d - 1) % 7]

Measured memory_bytes: 5484
#include<iostream>
#include<cmath>
#include<string>
#include<set>
#include<algorithm>
 
using namespace std;
 
int main(){
	string s;
	int K;
	cin >> s;
	cin >> K;
	
	set<string> set;
	
	for(int i=0;i < K;i++){
		for(int j=0;j < s.length() - i; j++){
			set.insert(s.substr(j, i+1));
		}
	}
	
	int _k = 0;
	for(auto i : set){
		_k++;
		if(_k == K){
 			cout << i <<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1664
using System;

namespace ABC046_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var aaa = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var n = aaa[0];
            var k = aaa[1];
            var ans = 1L;
            for(var i=0;i<n;i++)
            {
                if(i==0)
                {
                    ans *= k;
                }
                else
                {
                    ans *= k - 1;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int a[N];
vector<int>s[9];
void jg(int x){
	if(x>=1&&x<4e2) s[0].pb(x);
	else if(x>=4e2&&x<8e2) s[1].pb(x);
	else if(x>=8e2&&x<1200) s[2].pb(x);
	else if(x>=1200&&x<1600) s[3].pb(x);
	else if(x>=1600&&x<2000) s[4].pb(x);
	else if(x>=2000&&x<2400) s[5].pb(x);
	else if(x>=2400&&x<2800) s[6].pb(x);
	else if(x>=2800&&x<3200) s[7].pb(x);
	else s[8].pb(x);
}
int main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		jg(a[i]);
	}
	int mn=0,mx=0;
	for(int i=0;i<9;i++){
		if(i!=8){
			if(!s[i].empty()) mn++,mx++;
		}
		else {
		if(!mn) mn++;
		mx+=s[i].size();
		}
	}
	printf("%d %d\n",mn,mx);
	return 0;
}

Measured memory_bytes: 3764
while True:
    N, M, P, A, B = map(int, input().split())
    if not (N | M | P | A | B):
        break
    A, B = A - 1, B - 1
    T = [int(x) for x in input().split()]
    dp = [[float("inf")] * M for _ in range(1 << N)]
    dp[0][A] = 0
    edges = []
    for _ in range(P):
        s, t, c = map(int, input().split())
        s, t = s - 1, t - 1
        edges.append((s, t, c))
        edges.append((t, s, c))
    ans = float('inf')
    for state in range(1 << N):
        for s, t, c in edges:
            for k in range(N):
                if state >> k & 1 and dp[state][t] > dp[state & ~(1 << k)][s] + c / T[k]:
                    dp[state][t] = dp[state & ~(1 << k)][s] + c / T[k]
    ans = min(dp[state][B] for state in range(1 << N))
    print("Impossible" if ans == float("inf") else "{:.04f}".format(ans))

Measured memory_bytes: 7904
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;
signed main() {
	int n; cin >> n;
	set<string>st;
	map<string, int>m;
	for (int i = 0; i < n; i++) {
		string s; int p;
		cin >> s >> p;
		if (st.lower_bound(s) == st.end()) {
			st.insert(s);
			m[s] = 0;
		}
		else if(*(st.lower_bound(s)) != s){
		 	st.insert(s);
			m[s] = 0;   
		}
		m[s] += p;
	}
	vector<pair<int, string>>v;
	for (string s : st)v.push_back(make_pair(s.size(), s));
	sort(v.begin(), v.end());
	for (pair<int, string> i : v)cout << i.second << ' ' << m[i.second] << endl;
}


Measured memory_bytes: 3164
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  x:Integer;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(x);

    if x<1200 then   
      Writeln('ABC')
    else
      Writeln('ARC');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
import java.util.Scanner;


public class Main {
	
	public static class BIT {
		int[] dat;
		
		public BIT(int n){
			dat = new int[n + 1];
		}
		
		public void add(int k, int a){ // k : 0-indexed
			for(int i = k + 1; i < dat.length; i += i & -i){
				dat[i] += a;	
			}
		}
		
		public int sum(int s, int t){ // [s, t)
			if(s > 0) return sum(0, t) - sum(0, s);
			
			int ret = 0;
			for(int i = t; i > 0; i -= i & -i) {
				ret += dat[i];
			}
			return ret;
		}
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int n = sc.nextInt();
			final int k = sc.nextInt();
			
			if(n == 0 && k == 0){
				break;
			}
			
			BIT bit = new BIT(n);
			for(int i = 0; i < n; i++){
				bit.add(i, sc.nextInt());
			}
			
			int max = Integer.MIN_VALUE;
			for(int start = 0; start < n - k + 1; start++){
				max = Math.max(max, bit.sum(start, start + k));
				//System.out.println("[" + start + " " + (start + k) + ") = " + bit.sum(start, start + k));
			}
		
			System.out.println(max);
		}
	}
}

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

struct Data {
    int r, l;
};

int main() {
    std::string s;
    std::cin >> s;

    auto rls = std::unordered_map<int, Data>();

    for(uint32_t i = 0; i < s.size() - 1; ++i) {
        if(s[i] == 'R' && s[i + 1] == 'L') {
            rls[i] = Data{ 0, 0 };
        }
    }

    for(auto &entry: rls) {
        const int i = entry.first;

        int r = 0;
        for(int j = i; j >=0 && s[j] == 'R'; --j) {
            ++r;
        }
        entry.second.r = r;

        int l = 0;
        for(uint32_t j = i + 1; j < s.size() && s[j] == 'L'; ++j) {
            ++l;
        }
        entry.second.l = l;
    }

    auto answer = std::vector<int>(s.size(), 0);

    for(const auto entry: rls) {
        const int i = entry.first;
        const int r = entry.second.r;
        const int l = entry.second.l;

        answer[i] = (r + 1) / 2 + l / 2;
        answer[i + 1] = r / 2 + (l + 1) / 2;
    }

    for(const int a: answer) {
        std::cout << a << ' ';
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 2956
#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<cctype>
using namespace std;

#define ME '@'
#define EXIT '<'
#define WALL '#'
#define EMPTY '.'

struct Data{int x,y,on;};
bool operator<(Data a,Data b){
  return a.x!=b.x?a.x<b.x: (a.y!=b.y?a.y<b.y:a.on<b.on);
}

int main()
{
  int W,H;
  int i;
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  int ans;
  while(cin>>W>>H,W|H){
    vector<string>v(H);
    queue<Data>q;
    set<Data>visited;
    map<Data,int>cost;
    for(i=0;i<H;i++){
      cin>>v[i];
      if(v[i].find("@")!=string::npos){
	Data d;
	d.x=v[i].find("@");
	d.y=i;
	d.on=0;
	q.push(d);
	v[d.y][d.x]=EMPTY;
      }
    }

    ans=-1;
    while(q.size()){
      Data d=q.front();
      q.pop();
      if(ans!=-1)break;
      if(visited.count(d))continue;
      visited.insert(d);
      for(i=0;i<4;i++){
	Data dd=d;
	dd.x+=dx[i];
	dd.y+=dy[i];
	if(dd.x<0 || W<=dd.x || dd.y<0 || H<=dd.y)continue;
	if(v[dd.y][dd.x]==EXIT){
	  ans=cost[d]+1;
	  break;
	}else if(v[dd.y][dd.x]==WALL){
	  continue;
	}else if(v[dd.y][dd.x]==EMPTY){
	  q.push(dd);
	  cost[dd]=cost[d]+1;
	}else if(isupper(v[dd.y][dd.x])){
	  if( dd.on & ( 1<<(v[dd.y][dd.x]-'A') ) ){
	    q.push(dd);
	    cost[dd]=cost[d]+1;
	  }
	}else if(islower(v[dd.y][dd.x])){
	  dd.on ^= 1<<(v[dd.y][dd.x]-'a');
	  q.push(dd);
	  cost[dd]=cost[d]+1;
	}
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>
int main(){

double a,b,c;
scanf("%lf %lf %lf",&a,&b,&c);
double radian = acos(-1)/180;
double height = b * sin(c*radian);
double area = 0.5 * height * a;
double base = b * cos(c*radian);
double op_a = a - base;
double len_side = sqrt((op_a*op_a)+(height*height));
double circum = a + b + len_side;

printf("%.4lf %.4lf %.4lf\n",area,circum,height );
}


Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int main(int argc, char *argv[])
{
    vector<pair<int, int>> students;
    vector<pair<int, int>> checkpoints;
    int n, m;
    cin >> n >> m;

    students.reserve(n);
    checkpoints.reserve(m);

    for(int i = 0; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;
        students.emplace_back(a, b);
    }

    for(int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;
        checkpoints.emplace_back(a, b);
    }

    for(auto& s : students)
    {
        pair<int, int> closest = checkpoints[0];
        int i = 0;
        int ind = 0;
        for(auto& c : checkpoints)
        {
            if(abs(s.first - c.first) + abs(s.second - c.second) < abs(closest.first - s.first) + abs(closest.second - s.second))
            {
                closest = c;
                ind = i;
            }
            i++;
        }
        cout << ind + 1 << endl;
    }
}


Measured memory_bytes: 256
def makeSeqList(N,M,curList,res):
    if len(curList)==N:
        res.append(curList.copy())
        return

    for i in range(1,M+1):
        if len(curList)!=0 and i<curList[-1]:
            continue
        curList.append(i)
        makeSeqList(N,M,curList,res)
        del curList[-1]

def main():
    N,M,Q=map(int,input().split())
    quadList=[]
    for _ in range(Q):
        quadList.append(list(map(int,input().split())))
    res=[]
    makeSeqList(N,M,[],res)
    ans=-1
    for sequence in res:
        summ=0
        for q in quadList:
            if (sequence[q[1]-1]-sequence[q[0]-1])==q[2]:
                summ+=q[3]
        ans=max(ans,summ)
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 85416
N = gets.to_i
A = gets.split.map(&:to_i)
Q = gets.to_i
ANS = Array.new(10**5, 0)

go = 0
A.each do |v|
    ANS[v - 1] += 1
    go += v
end
# c g

Q.times do
    b, c = gets.split.map(&:to_i)
    tmp = ANS[b - 1]
    ANS[b - 1] = 0
    ANS[c - 1] += tmp

    go = go - tmp * b + tmp * c
    puts go
end


Measured memory_bytes: 22112
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
const long long N = 100005;
ll n, m, i, j, k, u, v, ans, t, color[N], a[N];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> u >> v;
		ans -= v;
		a[i] = u + v;
	}
	sort(a + 1, a + 1 + n);
	for (i = n; i >= 1; i -= 2)
		ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
   int a,b;
   scanf("%d%d",&a,&b);
   cout<<(1900*b+(a-b)*100)*pow(2,b)<<endl;
    return 0;
}
 //c*(x+1)+b*x


Measured memory_bytes: 256
var
  a,b:longint;
begin
  readln(a,b);
  if a mod 3 =0 then writeln('Possible')
                else if b mod 3=0 then writeln('Possible')
                                  else if (a+b) mod 3=0 then writeln('Possible')
                                                        else writeln('Impossible');
end.
                                                     

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  int r,g;
  cin >> r >> g;

  int ans = 2*g-r; 
  cout << ans << endl;
}

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

int main() {
	int m,n;
	cin>>m>>n;
	char a[m][n];
	int b[m][n];
	for(int i=0;i<m;i++)
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	bool fla=true;
	for(int i=0;i<n;i++){
		if(a[0][i]=='.'&&fla)
			b[0][i]=1;	
		else{
			b[0][i]=0;
			fla=false;
		}
	}
	fla=true;
	for(int i=0;i<m;i++){
		if(a[i][0]=='.'&&fla)
			b[i][0]=1;	
		else{
			b[i][0]=0;
			fla=false;
		}	
	}
	for(int i=1;i<m;i++){
		for(int j=1;j<n;j++){
			if(a[i][j]=='.')
				b[i][j]=(b[i-1][j]+b[i][j-1])%1000000007;
			else
				b[i][j]=0;
		}
	}
	cout<<b[m-1][n-1];
}

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

int main(){
    int n,x,y;
    cin >> n >> x >> y;
    x--;
    y--;
    vector<int> dist(n,0);
    int d=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            d = min(abs(j-i),min(abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x)));
            dist[d]++;
        }
    }
    for(int i=1;i<n;i++){
        cout << dist[i] << endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#1 <= T,X <= 100
T, X = map(float, input().split())
# 文字列の入力
#s = input()
t = T / X
# 出力
print(t)
#print("{} {}".format(a+b+c, s))

Measured memory_bytes: 2940
import sys
import math
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
Yes = lambda boolean: print('Yes') if boolean else print('No')
YES = lambda boolean: print('YES') if boolean else print('NO')
aint = lambda: int(input())
ints = lambda: list(map(int, input().split()))
is_even = lambda x: True if x%2==0 else False
zeros2d = lambda r,c: [[0 for col in range(c)] for row in range(r)]

R = aint()
print(2*R*math.pi)

Measured memory_bytes: 9488
#include<stdio.h>
#include<string.h>
int main(){
  int n,m,i,c=0,k=0;
  while(scanf("%d",&n)){
    scanf("%d",&m);
    c=k=0;
    if(n==0)break;
    int ioi=0,st=0;
    char a,mae='U';
    //  printf("%d\n",2*n+1);
    for(i=0;i<m;i++){
      scanf(" %c",&a);
      if(st==0&&a=='I'){
	ioi++;
	st=1;
	mae='I';
      }else if(st==1&&a=='O'&&mae=='I'){
	ioi++;
	mae='O';
      }else if(st==1&&a=='I'&&mae=='O'){
	ioi++;
	mae='I';
      }else{
	k=ioi-(2*n+1);
	if(k>=0){
	  c++;
	  k/=2;
	  c+=k;
	}
	if(a=='I'){
	  ioi=1;
	  st=1;
	  mae='I';
	}else{
	  ioi=0;
	  st=0;
	  mae='O';
	}
      }
      //printf("%d %c\n",ioi,a);
      //    printf("%d %d %d %d\n",ioi,c,k,i);
    }
    printf("%d\n",c);
  }
  return 0;
}


Measured memory_bytes: 596
N = int(input())
S = []
number = []
for i in range(N):
    s = input()
    if s in S:
       number[S.index(s)] += 1
    else:
        number.append(1)
        S.append(s)
M = int(input())
for i in range(M):
    s = input()
    if s in S:
        number[S.index(s)] -= 1

print(max(max(number),0))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int n;
int d3,d5,d7;
int ans,cnt;
int now;
void DFS(int k,int m)
{
	if(k > m)
	{
		if(d3&&d5&&d7&&now<=n)
		   ++cnt;
		return;
	}
	d3++;
	now*=10;
	now+=3;
	DFS(k+1,m);
	d3--;
	now-=3;
	now/=10;
	d5++;
	now*=10;
	now+=5;
	DFS(k+1,m);
	d5--;
	now-=5;
	now/=10;
	d7++;
	now*=10;
	now+=7;
	DFS(k+1,m);
	d7--;
	now-=7;
	now/=10;
}

int main()
{
	cin>>n;
	int s=n;
	int lens=0;
	while(s)
	{
		s/=10;
		lens++;
	}
	for(int i=3;i<=lens;++i)
	{
		now=cnt=d3=d5=d7=0;
		DFS(1,i);
		ans+=cnt;
	}
	printf("%d\n",ans);
	return 0;
 } 

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

typedef long long ll;
using namespace std;

bool check(string s)
{
    bool flag = true;
    for (char c : s)
    {
        if (c != s[0])
            flag = false;
    }
    return flag;
}

int main()
{
    string s;
    cin >> s;
    int m = s.size();
    for (char d = 'a'; d <= 'z'; d++)
    {
        string t = s;
        string _t = "";
        int count = 0;
        while (true)
        {
            if (check(t))
                break;
            for (int i = 0; i < t.size() - 1; i++)
            {
                if (t[i] == d || t[i + 1] == d)
                {
                    _t.push_back(d);
                }
                else
                {
                    _t.push_back(t[i]);
                }
            }
            count++;
            t = _t;
            _t = "";
        }
        m = min(count, m);
    }
    cout << m << endl;
}

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

int main() {
    long long T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    long long A = A1 - B1, B = A2 - B2;
    if(A < 0) { A = -A; B = -B;}

    if(A * T1 + B * T2 > 0) {
        cout << 0 << endl;
    } else if(A * T1 + B * T2 == 0) {
        cout << "infinity\n";
    } else {
        long long a = A * T1, b = (A * T1 + B * T2) * (-1);
        if(a % b == 0) cout << 2 * (a / b) << endl;
        else cout << 2 * (a / b) + 1 << endl;
    }
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
//#define N 500005a
#define all(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

bool is_prime(int x){
  for(int i = 2; i * i <= x; i++){
    if(x % i == 0){
      return false;
    }
  }
  return true;
}
const int N = 1e6 + 10;
int mp[N] = {};

int32_t main(){
  IOS;
  int tt = 1; 
  //cin >> tt;
  while(tt--){
    int n; cin >> n;
    int A[n];
    
    vector < int > primes;
    for(int i = 2; i < 1100; i++){
      if(is_prime(i)) primes.EB(i);
    }
   
    int g = 0;
    for(int i = 0; i < n; i++) {
      cin >> A[i];
      g = __gcd(A[i], g);
      if(A[i] == 1) continue;
      bool ok = true;
      for(auto x : primes){
        if(A[i] % x == 0){
          ok = false;
          mp[x]++;
          if(A[i] / x != x && x != A[i] && A[i] / x > 1000){
            mp[A[i] / x]++;
          }
        }
      }
      if(ok) mp[A[i]]++;
      
    }
    bool flag = true;
    
    for(auto x : mp){
      if(x > 1){
        flag = 0;
        break;
      }
    }
    
    if(flag) {
      cout << "pairwise coprime" << endl;
      break;
    }
    
    if(g == 1) {
      cout << "setwise coprime" << endl;
      break;
    }
    
    cout << "not coprime";
  
  }
  return 0;
}


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

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

#pragma GCC optimize("Ofast")



using namespace std;

bool is_integer( float x ){
    return floor(x) == x;
}
bool is_integer(double x){
    return floor(x) == x;
}


int main() {

    double n,k; cin >> n >> k;
    double ans = 0;
    double d = n;

    for(int i = 1; i <= n; i ++){
        if(i >= k) ans += 1/d;
        else{
            double tmpD = 1;
            double tmpI = i;

            while(tmpI < k){
                tmpI *= 2;
                tmpD *= 2;
            }

            ans += 1/(tmpD*d);
        }
    }

    cout << fixed << setprecision(13) << ans;


    return 0;
}











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

public class Main {
	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			int x = Integer.parseInt(br.readLine());

			int hour = x/3600;
			int min = (x-(hour*3600))/60;
			int sec = x-(min*60)-(hour*3600);
			System.out.println((hour)+":"+(min)+":"+(sec));


		}  catch (IOException e) {
			e.printStackTrace();
		}



	}

}

Measured memory_bytes: 24368
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;

ll n,m;

int main()
{
	scanf("%lld%lld",&n,&m);
	if(n==1&&m==1)
		cout<<1;
	else if(n==1)
		cout<<m-2;
	else if(m==1)
		cout<<n-2;
	else 
		cout<<(n-2)*(m-2);
}

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

int main() {
    int n;
    while (cin >> n, n) {
        int count = 0;
        vector<int> l(n+1), r(n+1);
        for (int i = 1; i <= n; i++) {
            char v, w;
            cin >> v >> w;

            if (v == 'r') {
                r[i] = r[i-1] ? 0 : 1;
                l[i] = l[i-1];
            } else {
                r[i] = r[i-1];
                l[i] = l[i-1] ? 0 : 1;
            }

            if (i > 1 && r[i] == l[i] && r[i] != r[i-2] && l[i] != l[i-2]) count++;
        }

        cout << count << endl;
    }

    return 0;
}



Measured memory_bytes: 3060
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize
    }

    let mut ans = 0;
    for j in 1..=n {
        let k = n / j;
        ans += j * k * (k+1) / 2;
    }
    println!("{}", ans);
}


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

int main(){
    int h,w;
    while ((bool) true){
        cin >> h >> w;
        if (h == 0){
            break;
        };
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if ((i+j)%2 == 0){
                    cout << "#";
                }
                else{
                    cout << ".";
                }  
            };
            cout << "" << endl;
        };
        cout << "" << endl;
    }  
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> v;
set<int> modi;
unordered_map<int, int> dig;
bool str_mon_inc=true;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=0; i<n; i++)
    {
        int sza;
        cin>>sza;
        v.push_back(sza);
        if(i>0 && v[i]<=v[i-1]) str_mon_inc=false;
    }
    int elso=1;
    int utolso=n;
    while(elso<=utolso)
    {
        int kozep=(elso+utolso)/2;
        bool lehetseges=true;
        modi.clear();
        dig.clear();
        if(kozep==1)
        {
            if(str_mon_inc) utolso=kozep-1;
            else elso=kozep+1;
            continue;
        }
        for(int i=1; i<n; i++)
        {
            if(v[i]>v[i-1])
            {
                auto it=modi.lower_bound(v[i-1]+1);
                while(it!=modi.end())
                {
                    dig[*it]=0;
                    modi.erase(it++);
                }
            }
            else
            {
                int cnt=v[i];
                while(cnt>0)
                {
                    if(dig[cnt]+1<kozep)
                    {
                        dig[cnt]++;
                        modi.insert(cnt);
                        break;
                    }
                    else
                    {
                        dig[cnt]=0;
                        cnt--;
                    }
                }
                if(cnt==0)
                {
                    lehetseges=false;
                    break;
                }
            }
        }
        if(lehetseges) utolso=kozep-1;
        else elso=kozep+1;
    }
    cout<<elso<<endl;
    return 0;
}


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

int main(){
    int n;
    scanf("%d",&n);
    int ct[n];
    memset(ct,0,sizeof(ct));
    for (int i = 0; i < n; i++){
        int x;
        scanf("%d",&x);
        ct[--x]++;
    }
    int a[n+1];
    memset(a,0,sizeof(a));
    for (int i = 0; i < n; i++){
        if (ct[i]) a[ct[i]]++;
    }
    int total = n;
    int cur = n;
    for (int i = 1; i <= n; i++){
        while (total < i*cur){
            total -= a[cur];
            a[cur-1] += a[cur];
            a[cur] = 0;
            cur--;
        }
        printf("%d\n",cur);
    }

}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
    	Scanner input = new Scanner(System.in);
    	while(true){
    		int n = input.nextInt();
    		int s = input.nextInt();
    		if(n == 0 && s == 0)break;
    		System.out.println(count(n,s,0,0));
    	}
    }
    
    public static int count(int n,int s,int sum,int stnum){
    	if(n == 0 && sum == s)return 1;
    	if(stnum == 10 || sum > s || n == 0)return 0;
    	return count(n-1,s,sum+stnum,stnum+1)+count(n,s,sum,stnum+1);
    }
}

Measured memory_bytes: 18024
loop do
  a = gets.split.map(&:to_i)
  ans = ""
  break if a[0] == 0 && a[1] == 0
  for i in 0...a[0] do
    for j in 0...a[1] do
      ans << "#" if j % 2 == 1 && i % 2 == 1
      ans << "#" if j % 2 == 0 && i % 2 == 0
      ans << "." if j % 2 == 1 && i % 2 == 0
      ans << "." if j % 2 == 0 && i % 2 == 1
    end
    ans << "\n"
  end
  ans << "\n"
  puts ans
end

Measured memory_bytes: 6128
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define loop(i,n) for(int i=0;i<(n);i++)
#define pool(i,n) for(int i=(n)-1;i>=0;i--)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define tnoc(i,n) for(int i=(n);i>=1;i--)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define cric(i,a,b) for(int i=(b);i>=(a);i--)
#define sub(i,a) for(int i=a;i;i=((i-1)&(a)))
#define subs(i,a) for(int i=a;i>=0;i=(!i?-1:((i-1)&(a))))
#define subt(i,a) for(int i=((a-1)&a);i;i=((i-1)&(a)))
#define subst(i,a) for(int i=((a-1)&a);i>=0;i=(!i?-1:((i-1)&(a))))
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define parse(i,s) for(int i=0;s[i];i++)

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mak make_pair

#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define ws WSrAkIoi2333wSraKIoIWSraKiOi
#define left left_jTjTJtJtIoiiOiioIAuaU66666jtIOIau
#define hash whYusEthiSnamE_caNyoUusEothERnaMesliKeHSH

#define Mask(a) (1ll<<(a))
#define Maskx(a,x) ((a)<<(x))
#define Full(a) ((1ll<<(a))-1)
#define Bit(a,x) (((a)>>(x))&1)
#define all(a) (a).begin(),(a).end()
#define SZ(a) ((int)((a).size()))

typedef long long ll;
typedef long double lf;

const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const lf inF=11451419198101145141919810.1145141919810;
const lf pi=acosl(-1);
/* Source code starts here */

ll lb[64],flb[64];
int n;
ll a[205];
char s[205];

bool add(ll lb[],ll x){
	pool(i,63){
		if(!Bit(x,i))continue;
		if(!lb[i])return (lb[i]=x),1;
		x^=lb[i];
	}
	return 0;
}

void solve(){
	memset(lb,0,sizeof(lb));
	scanf("%d",&n);
	cont(i,n)scanf("%lld",a+i);
	scanf("%s",s+1);
	tnoc(i,n){
		if(s[i]=='0')add(lb,a[i]);
		else{
			memcpy(flb,lb,sizeof(lb));
			if(add(flb,a[i]))return void(puts("1"));
		}
	}
	puts("0");
}

int main(){
	int T;
	scanf("%d",&T);
	while(T--)solve();
	return 0;
}

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

using namespace std;

typedef long long LL;
const int N = 1e7 + 2;
int f[N]{0, 1};
int p[N], tot;
bool mk[N];

void euler() {
    for (int i = 2; i < N; i++) {
        if (!mk[i]) p[tot++] = i, f[i] = 2;
        for (int j = 0; j < tot && i * p[j] < N; j++) {
            int x = i * p[j];
            mk[x] = true;
            if (i % p[j]) {
                f[x] = f[i] * 2;
            }
            else {
                int t = i, c = 0;
                while (t % p[j] == 0) {
                    c++, t /= p[j];
                }
                f[x] = f[t] * (c + 2);
                break;
            }
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    euler();
    LL n;
    cin >> n;
    LL ans = 0;
    for (LL i = 1; i <= n; i++) ans += f[i] * i;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 55044
#include "bits/stdc++.h"

/*#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>*/

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct UnionFind
{
	vector<int> parent;
	vector<int> rank;

	UnionFind(int N) :parent(N, 0), rank(N, 0)
	{
		rep(i, 0, N)
		{
			parent[i] = i;
		}
	}

	int find(int x)
	{
		if (parent[x] == x)
		{
			return x;
		}
		else
		{
			return parent[x] = find(parent[x]);
		}
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (x == y)
		{
			return;
		}

		if (rank[x] < rank[y])
		{
			parent[x] = y;
		}
		else
		{
			parent[y] = x;
			if (rank[x] == rank[y])
			{
				rank[x]++;
			}
		}
	}

	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};

vector<int> G[100005];
int anc[100005];

void dfs(int nv, int tanc)
{
	if (anc[nv] == tanc || anc[nv] == nv)
	{
		return;
	}
	anc[nv] = tanc;
	for (auto n : G[nv])
	{
		dfs(n, tanc);
	}
}

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

	while (true)
	{
		int N, Q;
		cin >> N >> Q;
		if (N + Q == 0)
		{
			break;
		}

		rep(i, 0, N)
		{
			G[i].clear();
			anc[i] = 0;
		}

		int to;
		rep(i, 0, N - 1)
		{
			cin >> to;
			G[to - 1].push_back(i + 1);
		}
		char c;
		int v;
		ll ans = 0;
		rep(i, 0, Q)
		{
			cin >> c >> v;
			if (c == 'M')
			{
				dfs(v - 1, v - 1);
			}
			else
			{
				ans += anc[v - 1] + 1;
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 11880
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  string S, T;
  cin >> S >> T;
  ll ans = 0;
  for(int i = 0; i < S.size(); i++) {
    if(S.at(i) != T.at(i)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3832
#include<stdio.h>
int fish[21]={0};
int n;
int a,b;
int memo[2]={0};
int date=100;

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

    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&a,&b);
        if(a<date)date=a;
        memo[0]=date;
        fish[a] +=b;
    }
    for(int i=0;i<21;i++)
    {
        if(fish[i]>memo[1])
        {
            memo[0]=i;
            memo[1]=fish[i];
        }
    }
    printf("%d %d\n",memo[0],memo[1]);
    return 0;
}

Measured memory_bytes: 1028
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<ld,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
int s[2],g[2];
ll x[1009], y[1009], r[1009];
ld G[1009][1009];

ld calc(int i,int j){
    ld xlen=abs(x[i]-x[j]);
    ld ylen=abs(y[i]-y[j]);
    ld dist=sqrt(xlen*xlen+ylen*ylen);
    return max((ld)0,dist-r[i]-r[j]);
}

ld d[1009];
ld dijkstra(int s, int t) {
    
    rep1(i,N) d[i] = LLINF;
    priority_queue< pii, vector<pii>, greater<pii> > que;   // first:cost second:頂点 cost基準の昇順
    que.push({0,s});
    d[s] = 0;
    
    while(!que.empty()){
        pii p = que.top(); que.pop();
        int u = p.second;
        if(d[u]<p.first) continue;
        rep(v,N){
            if(d[v]>G[u][v]+d[u]){
                d[v]=G[u][v]+d[u];
                que.push({d[v],v});
            }
        }
    }
    return d[t];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    rep(i,2) cin>>s[i];
    rep(i,2) cin>>g[i];
    cin>>N;
    
    rep1(i,N) cin>>x[i]>>y[i]>>r[i];
    x[0]=s[0];y[0]=s[1];
    x[N+1]=g[0];y[N+1]=g[1];
    
    N+=2;
    rep(i,N)for(int j=i+1;j<N;j++){
        G[i][j]=G[j][i]=calc(i,j);
    }
    
    ld ans=dijkstra(0,N-1);
    printf("%.12llf\n",ans);
}

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

int main(){
    int q,x;
    char com[20];
    list<int> v;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%s", com);
        if(com[0]=='i'){
            scanf("%d",&x);
            v.push_front(x);
        }
        else if(com[6]=='L'){
            v.pop_back();
        }
        else if(com[6]=='F'){
            v.pop_front();
        }
        else if(com[0]=='d'){
            scanf("%d",&x);
            for(list<int>::iterator it=v.begin();it!=v.end();it++){
                if(*it==x){
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i=0;
    for(list<int>::iterator it=v.begin();it!=v.end();it++){
        if(i++)printf(" ");
        printf("%d",*it);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 34436
#include<cstdio>
#include<cstring>
using namespace std;

int len,cnt;
char s[20];
bool flag;

int main() {
	scanf("%s",s+1);
	len=strlen(s+1);
	if(s[1]!='A'||s[2]=='C'||s[len]=='C') {
		printf("WA\n");
		return 0;
	}
	for(int i=2;i<=len;i++) {
		if(s[i]!='C'&&s[i]>='A'&&s[i]<='Z') {
			printf("WA\n");
			return 0;
		}
		if(s[i]=='C') {
			if(!flag)
				flag=true;
			else {
				printf("WA\n");
				return 0;
			}
		}
	}
	if(flag)
		printf("AC\n");
	else printf("WA\n");
	return 0;
}

Measured memory_bytes: 128
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, C):
    C = list(C)
    ans = 0
    l = 0
    r = N - 1
    while l < r:
        while l < N and C[l] == 'R': l += 1
        while r >= 0 and C[r] == 'W': r -= 1
        if l < r:
            C[l], C[r] = C[r], C[l]
            ans += 1
    print(ans)

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    C = input().rstrip()
    main(N, C)


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

#define rep(i, a, n) for (int i = a; i < n; i++)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  if (A + B <= 16 && A <= 8 && B <= 8)
    cout << "Yay!" << endl;
  else
    cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
#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,k; cin  >> n >> k;
    vector<int> tmp;
    rep(i,k){
        int d; cin >> d;
        for(int j = 0; j < d;++j){
            int p; cin >> p;
            tmp.push_back(p);
        }
    }
    sort(tmp.begin(),tmp.end());
    tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());
    int ans = n - tmp.size();
    cout << ans << endl;

}


Measured memory_bytes: 3644
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstdlib>

using namespace std;

int n, m, a[100], b[100], c[100], d[100], i, j, mn = 1e9, minn;

int main()
{
    
    cin >> n >> m;
    for(i = 1;i <= n; i++)
        cin >> a[i] >> b[i];
    for(i = 1;i <= m; i++)
        cin >> c[i] >> d[i];
    for(i = 1;i <= n; i++)
    {
        mn = 1e9;
        for(j = 1;j <= m; j++)
            if(abs(c[j] - a[i]) + abs(d[j] - b[i]) < mn)
            {
                mn = abs(c[j] - a[i]) + abs(d[j] - b[i]);
                minn = j;
            }
        cout << minn << endl;
    }
    return 0;
} 

Measured memory_bytes: 256
def solve():
    N = int(input())
    S = input()

    mx = 0
    for i in range(1,N):
        former = set(S[:i])
        latter = set(S[i:])

        cnt = 0
        for elem in former:
            if elem in latter:
                cnt += 1
        
        mx = max(cnt,mx)
    
    print(mx)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 39280