akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MP make_pair
#define P pair<int,int>
using namespace std;
const int N=1e5+5;
const int M=11;
int first[N],cnt,vis[N][M],n,m,q,v[N],c[N],d[N],ans[N];
struct edge{int nt,to;}e[N<<1];
void add(int u,int v){e[++cnt]=(edge){first[u],v};first[u]=cnt;}
bool check(int s,int d)
{
	for(int i=d;i<M;++i) if(vis[s][i]) return true;
	return false;
}
void solve(int v,int d,int c)
{
	if(check(v,d)) return;
	queue<P>q;
	q.push(MP(v,d)),vis[v][d]=1;
	while(!q.empty())
	{
		int u=q.front().first,w=q.front().second-1;q.pop();
		if(!ans[u]) ans[u]=c;
		if(w==-1) continue;
		for(int i=first[u];i;i=e[i].nt)
		{
			int x=e[i].to;
			if(check(x,w)) continue;
			vis[x][w]=1,q.push(MP(x,w));
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,a,b;i<=m;++i) scanf("%d%d",&a,&b),add(a,b),add(b,a);
	scanf("%d",&q);
	for(int i=1;i<=q;++i) scanf("%d%d%d",&v[i],&d[i],&c[i]);
	for(int i=q;i;--i) solve(v[i],d[i],c[i]);
	for(int i=1;i<=n;++i) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 8920
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author __shangu__
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CID solver = new CID();
        solver.solve(1, in, out);
        out.close();
    }

    static class CID {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt(), cnt[] = new int[n + 10];
            City[] cities = new City[m];
            for (int i = 0; i < m; ++i) {
                cities[i] = new City();
                cities[i].p = in.nextInt();
                cities[i].y = in.nextInt();
                cities[i].idx = i;
            }
            Arrays.sort(cities, Comparator.comparingInt(a -> a.y));
            String ans[] = new String[m];
            for (int i = 0; i < m; ++i) {
                int p = cities[i].p, idx = cities[i].idx;
                StringBuilder stringBuilder = new StringBuilder(String.format("%06d", p)).append(String.format("%06d", ++cnt[p]));
                ans[idx] = stringBuilder.toString();
            }
            for (int i = 0; i < m; ++i) out.println(ans[i]);
        }

        class City {
            int p;
            int y;
            int idx;

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }
}



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

int main(){
  int w,h,n;
  cin >> w >> h >> n;
  vector<vector<int>>hyo(n,vector<int>(3));
  for(int i=0;i<n;i++)
    cin >> hyo.at(i).at(0) >> hyo.at(i).at(1) >> hyo.at(i).at(2);
  int lx=0,ly=0,rx=w,ry=h;
  for(int i=0;i<n;i++){
    if(hyo.at(i).at(2)==1){
     if(hyo.at(i).at(0)>lx)
       lx=hyo.at(i).at(0);
    }else if(hyo.at(i).at(2)==2){
     if(hyo.at(i).at(0)<rx)
       rx=hyo.at(i).at(0);
    }else if(hyo.at(i).at(2)==3){
     if(hyo.at(i).at(1)>ly)
       ly=hyo.at(i).at(1);
    }else if(hyo.at(i).at(2)==4){
     if(hyo.at(i).at(1)<ry)
       ry=hyo.at(i).at(1);
    }
  }
    if(rx-lx>0&&ry-ly>0)
      cout << (rx-lx)*(ry-ly) << endl;
    else
      cout << 0;
    exit(0);
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n;
  cin>>n;
  if(n==1)
  {
    cout<<0;
    return 0;
  }
  map<ll,ll> mp;
  ll y=n;
  while(n>1 && n%2==0)
  {
      n/=2;
      mp[2]++;
  }
  for(ll i=3;i*i<=n;i+=2)
  {
      while(n>1 && n%i==0)
      {
          n/=i;
          mp[i]++;
      }
  }
  if(n>2)
  mp[n]++;
  ll ans=0;
  for(auto &it:mp)
  {
      ll x=it.second;
      ll t=1;
      for(ll i=1;i<=x;i++)
      {
          t*=(it.first);
          if((y%t)==0)
          {
            y/=t;
            ans++;
          }
      }
      if(y==1)
      break;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3620
ary = gets.chomp.split('').map(&:to_i)

if ary.size == 1 then
  max = ary[0]
else
  if ary[0] == 9 then
    if ary.sort.uniq[0] == 9 then   # 全て 9                                                     
      max = 9 * (ary.size)
    else
      max = 8 + 9 * (ary.size-1)
    end
  else
    if ary[1..-1].sort.uniq[0] == 9 then   # 2 桁目以降が全て 9                                  
      max = ary[0] + 9 * (ary.size-1)
    else
      max = (ary[0]-1) + 9 * (ary.size-1)
    end
  end
end

puts max

Measured memory_bytes: 1788
#include <iostream>
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pii pair<int , int>
#define mpi make_pair
#define F first
#define S second
#define pb push_back
#define fl(i , n) for(int i = 0;i<n;i++)


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

    vector<vector<int>> mat(n , vector<int>(n-1 , 0));

    for(int i = 0 ; i < n;i++)
    {
        for(int j = 0 ; j < n-1;j++)
        {
            cin>>mat[i][j];
            mat[i][j]--;
        }
    }

    vector<int> poin(n , 0);

    set<pii> fin;
    queue<pii> qe;
    int ans = 0;
    for(int i = 0;i<n;i++)
    {
        int u , v ;
        u = i ; v = mat[i][poin[i]];
        if(fin.find(mpi(v , u)) == fin.end())
        {
            fin.insert(mpi(u , v));
        }
        else
        {
            qe.push(mpi(u , 1));
            qe.push(mpi(v , 1));
        }
    }

    while(!qe.empty())
    {
        pii tp = qe.front();qe.pop();
        ans = tp.S;
        poin[tp.F]++;
        if(poin[tp.F]!=n-1)
        {
            int u , v ;
            u = tp.F ; v = mat[u][poin[u]];
            if(fin.find(mpi(v , u)) == fin.end())
            {
                fin.insert(mpi(u , v));
            }
            else
            {
                qe.push(mpi(u , tp.S+1));
                qe.push(mpi(v , tp.S+1));
                // poin[u]++;
                // poin[v]++;
            }
        }
    }


    int flag = 0;
    for(int i = 0 ; i<n;i++)
    {   
        // cout<<poin[i]<<" ";
        if(poin[i]!=n-1)
        {
            flag = 1;
            break;
        }
    }

    if(flag == 1)cout<<-1<<endl;
    else cout<<ans<<endl;
    

	return 0;
}

Measured memory_bytes: 27648
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
using namespace std;

int main()
{
	int k, x;
	cin >> k >> x;
	for (int i = max(-1000000, x - (k - 1)); i <= min(1000000, x + (k - 1)); i++) {
		cout << i << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  char s[2][3];
  int i,j;
  for(i=0;i<3;i++){
    scanf("%c",&s[0][i]);
  }
  getchar();
  for(i=0;i<3;i++){
    scanf("%c",&s[1][i]);
  }
  int flag=1;
  for(j=0;j<3;j++){
    //printf("%c %c\n",s[0][j],s[1][2-j]);
    if(s[0][j]!=s[1][2-j]) flag=0;
  }
  if(flag) printf("YES\n");
  else printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

signed main(){
  Int n,t,a;cin >> n >> t >> a;
  vector<Int> h(n);
  for(Int i=0;i<n;i++) cin >> h[i];
  t*=1000;a*=1000;
  auto calc=[&](Int x){return abs((t-x*6)-a);};
  Int ans = 0;
  for(Int i=0;i<n;i++){
    if(calc(h[i])<calc(h[ans])) ans = i;
  }
  cout << ans+1 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int i, N;
  int cnt = 0;
  
  cin >> N;
  
  int *A = new int[N];
  int *a = new int[N];
  
  for(i = 0; i < N; i++){
    cin >> A[i];
    
    if(!(A[i]%2)){
      a[cnt] = A[i]/2;
      cnt++;
    }
  }
  
  for(i = 0; i < cnt; i++){
    if(a[i]%3 && a[i]%5){
      cout << "DENIED" << endl;
      return 0;
    }
  }
  
  cout << "APPROVED" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int main(){
    int n,m;
    cin >> n >> m;
    map<int,int>ma;
    vector<int>c;
    for(int i=0;i<m;i++){
        vector<int>d(2);
        cin >> d.at(0)>>d.at(1);
        sort(d.begin(),d.end());
        if(d.at(0)==1){
            c.push_back(d.at(1));
        }
        if(d.at(1)==n){
            if(!ma.count(d.at(0))){
                ma[d.at(0)]=n;
            }
        }
    }
    for(int i=0;i<c.size();i++){
        if(ma.count(c.at(i))){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout <<"IMPOSSIBLE"<<endl;
}



Measured memory_bytes: 5368
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int v = 0, c = 0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (char d : s)
    {
        if (d == 'I')
            c++;
        else
            c--;
        v = max(v, c);
    }
    cout << v;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	bool b[100];
	for(int i=0; i<100; i++) b[i]=false;
	int d;
	int ans=0;
	for(int i=0; i<n; i++){
		cin >> d;
		if(!b[d-1]){
			ans++;
			b[d-1]=true;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
ct = [list(map(int, input().split())) for _ in range(n)]

c = 1001
for i in range(n):
    if ct[i][0] < c and ct[i][1] <= t:
        c = ct[i][0]



if c == 1001:
    print("TLE")
else:
    print(c)



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

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

    int ans = 0;
    for (int i = 1; i < N-1; i++) {
        int cntr_x[30] = {}, cntr_y[30] = {};
        for (int j = 0; j < i; j++) {
            cntr_x[S.at(j)-'a']++;
        }
        for (int j = i; j < N; j++) {
            cntr_y[S.at(j)-'a']++;
        }
        int tmp = 0;
        for (int j = 0; j < 30; j++) {
            if (cntr_x[j] && cntr_y[j]) {
                tmp++;
            }
        }
        ans = max (ans, tmp);
    }

    cout << ans << endl;
}

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

int main() {
  int t, n, s, f;
  for(;;) {
    cin >> t;
    if(t == 0) break;
    cin >> n;
    int sum = 0;
    for(int i=0; i<n; ++i) {
      cin >> s >> f;
      sum += f - s;
    }
    if(sum >= t) cout << "OK" << endl;
    else cout << t - sum << endl;
  }
}




Measured memory_bytes: 3096
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scan =  new Scanner(System.in);
		try {
			int a = Integer.parseInt(scan.next());
			int b = Integer.parseInt(scan.next());
			System.out.println((a * b) + " " + ((a * 2) + (b * 2)));
		} catch (Exception e) {
			System.exit(0);
		}
	}
}

Measured memory_bytes: 26000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long N, long long T, long long A, std::vector<long long> H){
    ll ans = 0;
    ll sub = LLONG_MAX;

    
    for (int i = 0; i < N; i++)
    {
        ll tmp = T*1000 - H[i] * 6;
        if(abs(tmp-A*1000) < abs(sub-A*1000)){
            ans = i+1;
            sub = tmp;
        }
    }
    
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long T;
    scanf("%lld",&T);
    long long A;
    scanf("%lld",&A);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, T, A, std::move(H));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n;
    cin >> n;
    cin.ignore();
    int a = 0, b = 0;
    for (int i = 0; i < n; i++) {
        string str1, str2;
        cin >> str1 >> str2;
        bool flag = false;
        for (int i = 0; i < min(str1.length(), str2.length()); i++) {
            if (!flag && str1[i] != str2[i]) {
                str1[i] > str2[i] ? a += 3 : b += 3;
                flag = true;
            }
        }
        if (!flag) {
            if (str1.length() == str2.length()) {
                a++; b++;
            } else {
                str1.length() > str2.length() ? a += 3 : b += 3;
            }
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

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


int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(true){
    C-=B;
    if(C<=0){
      cout << "Yes" << endl;
      return 0;
    }
    A-=D;
    if(A<=0){
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3636
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
void fo (){fflush(stdout);}
using namespace std;
int main ()
{
  string x , y ;
  cin >> x >> y;
  x += y ;
  int a = 0 ;
  for (int i = SZ(x)-1 , k = 1;i >=0 ; i-- , k*=10)
  a += ((int)x[i] - '0') * k ;
  int b = sqrt (a);
  if (a == b * b )
  printf ("Yes\n");
  else
  printf ("No\n"); 
  //cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;

}


Measured memory_bytes: 256
/*	ex7_3
	suzuto	*/

  #include <stdio.h>
  #include <stdlib.h>

  int main(void){
    char **grid_ptr, ins; /*変数の宣言*/
    int *height_ptr, *width_ptr, height, width, i, j;

    scanf("%d %d", &height, &width); /*縦横の長さを入力*/
    height_ptr = (int*)calloc(height, sizeof(int)); /*圧縮後に残る行を記憶*/
    if(height_ptr == NULL){ /*エラー出力*/
      fprintf(stderr, "Memory allocation error.\n");
      return 1;
    }
    for(i = 0; i < height; i++){
      height_ptr[i] = 0; /*height_ptrを初期化*/
    }
    width_ptr = (int*)calloc(width, sizeof(int)); /*圧縮後に残る列を出力*/
    if(width_ptr == NULL){ /*エラー出力*/
      fprintf(stderr, "Memory allocation error.\n");
      return 1;
    }
    for(i = 0; i < width; i++){
      width_ptr[i] = 0; /*width_ptrを初期化*/
    }
    grid_ptr = (char**)calloc(height, sizeof(char*)); /*char*型配列を確保*/
    if(grid_ptr == NULL){ /*エラー出力*/
      fprintf(stderr, "Memory allocation error.\n");
      return 1;
    }
    for(i = 0; i < height; i++){
      grid_ptr[i] = (char*)calloc(width, sizeof(char)); /*char型配列を確保し入力を記憶する二次元配列が完成*/
      if(grid_ptr[i] == NULL){ /*エラー出力*/
        fprintf(stderr, "Memory allocation error.\n");
        return 1;
      }
    }
    for(i = 0; i < height; i++){
      for(j = 0; j < width; j++){
        scanf(" %c", &ins); /*入力insに一時的に記憶*/
        grid_ptr[i][j] = ins; /*入力を記憶用の配列に反映*/
        if(ins == '#'){ /*黒のある行、および列は圧縮により消えない*/
          height_ptr[i] = 1;
          width_ptr[j] = 1;
        }
      }
    }
    for(i = 0; i < height; i++){
      if(height_ptr[i] == 1){ /*height_ptrが初期値でないときその行は残る*/
        for(j = 0; j < width; j++){
          if(width_ptr[j] == 1){ /*width_ptrが初期値でないときその列は残る*/
            printf("%c", grid_ptr[i][j]); /*この点は残っているので出力*/
          }
        }
        printf("\n");
      }
    }

    /*各々の使用済みの動的確保した破裂を解放*/
    free(height_ptr);
    free(width_ptr);
    for(i = 0; i < height; i++){
      free(grid_ptr[i]);
    }
    free(grid_ptr);
    return 0;
  }


Measured memory_bytes: 1636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool srt( pair < int , int > a, pair < int , int > b){
    return a.first != b.first ? a.first>b.first : a.second<b.second;
}
const ll oo=1e18;
int dx[8]={1,-1,0,0,1,-1,-1,1};
int dy[8]={0,0,1,-1,1,-1,1,-1};
const int N = 100050;

int main(){
    int n;
    cin>>n;
    map<string,int>s;
    int mx=0,mn=N;
    while(n--){
        string x;
        cin>>x;
        s[x]++;
    }
    int m;
    cin>>m;
    map<string,int>v;
    while(m--){
        string x;
        cin>>x;
        v[x]++;
    }
    map<string,int>::iterator it;
    for(it=s.begin();it!=s.end();it++){
        if(v[it->first]>=it->second)continue;
        int u=v[it->first];
        int y=it->second;
        y-=u;
        mx=max(mx,y);
    }
    cout<<mx;
    return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
K = int(input())

def gcd(*numbers):
    return reduce(math.gcd, numbers)

out = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            out += gcd(a,b,c)

print(out)


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

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

	if (N & 1) {
		cout << "No" << endl;
	} else if (S.substr(0, N/2) == S.substr(N/2, N/2)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

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

int main(int argc, char const *argv[]) {
  int N;
  ll INF = 1000000007;
  std::cin >> N;
  ll sa = INF, S=0;
  std::vector<int> A(N), B(N);
  for(int i=0;i<N;i++){
    std::cin >> A[i] >> B[i];
    S+=A[i];
    if(A[i]>B[i]) sa = (sa>B[i]?B[i]:sa);
  }
  if(sa==INF) std::cout << 0 << '\n';
  else std::cout << S - sa << '\n';
  return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 3; i++)
    {
        if ((a * b * i) % 2 == 1)
        {
            OP("Yes");
            return 0;
        }
    }
    OP("No");
    return 0;
}

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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define REPA( i, n )	FOR( i, 1, n )
#define FORR( i, m, n ) for( int (i) = (m); (i) >= 0; (i)-- )
#define ALL( a )        (a).begin(), (a).end()             
#define MP( a, b )		make_pair( (a), (b) )
#define fi				first
#define se				second

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main() {
	int n, k; cin >> n >> k;
	string s; cin >> s;


	s[k - 1] += 32;

	cout << s << endl;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<ll,ll> pii;
template<typename T> using vec=std::vector<T>;

const ll inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    ll n,x0,y0,t;
    cin >> n >> x0 >> y0 >> t;

    static bool is_street[51][51][51][51];
    rep(i,0,n){
        ll xs,ys,xe,ye;
        cin >> xs >> ys >> xe >> ye;
        if(xs>xe) swap(xs,xe);
        if(ys>ye) swap(ys,ye);
        if(xs==xe) rep(y,ys,ye) is_street[xs][y][xs][y+1]=is_street[xs][y+1][xs][y]=true;
        if(ys==ye) rep(x,xs,xe) is_street[x][ys][x+1][ys]=is_street[x+1][ys][x][ys]=true;
    }
    int cs[1024],sum=0;
    fill_n((int*)cs,1024,-1);
    rep(i,0,t){
        ll d;
        char c;
        cin >> d >> c;
        sum+=d;
        if(c=='E') cs[sum]=0;
        if(c=='N') cs[sum]=1;
        if(c=='W') cs[sum]=2;
        if(c=='S') cs[sum]=3;
    }

    const ll dx[]={1,0,-1,0},dy[]={0,1,0,-1};
    static bool dp[1024][51][51][4];
    static bool done[1024][51][51][4];
    function<bool(int,int,int,int)> rec=[&](int dist,int x,int y,int dir){
        assert(x<=50);
        assert(y<=50);
        auto &res=dp[dist][x][y][dir];
        if(done[dist][x][y][dir]) return res;
        done[dist][x][y][dir]=true;
        if(!dist) return res=(x==x0 and y==y0);
        rep(i,0,4){
            int px=x-dx[i],py=y-dy[i];
            if(px<0 or 50<px or py<0 or 50<py or !is_street[x][y][px][py]) continue;
            if((i+2)%4==dir) continue;
            if(cs[dist]!=-1 and dir!=cs[dist] and i!=cs[dist]) continue;
            res|=rec(dist-1,px,py,i);
        }
        return res;
    };

    rep(x,0,51) rep(y,0,51){
        bool ok=false;
        rep(i,0,4){
            int nx=x+dx[i],ny=y+dy[i];
            if(nx<0 or 50<nx or ny<0 or 50<ny or !is_street[x][y][nx][ny]) continue;
            ok|=rec(sum,x,y,i);
        }
        if(ok) cout << x << " " << y << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 17500
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n,taroup = 0,hanakop = 0;
    string tarou, hanako;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        cin >> tarou >> hanako;
        if (tarou == hanako) {
            taroup += 1;
            hanakop += 1;
        }
        else if (tarou > hanako) taroup += 3;
        else hanakop += 3;
    }

    printf("%d %d\n", taroup, hanakop);

    return 0;
}

Measured memory_bytes: 3268
PROGRAM piyo
      IMPLICIT NONE
      INTEGER,PARAMETER :: prec = 16
      integer :: numC,numT,x,y
      
      read*,x,y
      
      do numC = 0,100
        do numT = 0,100
          if( numC+numT/=x ) cycle
          
          if( numC*2+numT*4==y )then
            print'(a)','Yes'
            stop
          end if
        end do
      end do
      
      print'(a)','No'
      
      
      
      
      stop
      !debugg
      
      
      
      END PROGRAM

Measured memory_bytes: 2864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 300010;
int n, val[N];
int main() {
  read(n);
  rep (i, 1, n) read(val[i]);
  int cur = 0, key = 0, las1, las2, rec, mn, mx;
  rep (i, 1, n) {
    if (cur == 0) {
      if (val[i] == i) continue;
      key = i&1;
      cur = 1;
      rec = i;
      las2 = 0;
      las1 = val[i];
      mx = mn = val[i];
    } else {
      if ((i&1) == key) {
	if (i == val[i]) {
	  puts("No");
	  return 0;
	}
	if (val[i] < i) {
	  if (val[i] < las2) {
	    puts("No");
	    return 0;
	  }
	  las2 = val[i];
	} else {
	  if (val[i] < las1) {
	    puts("No");
	    return 0;
	  }
	  las1 = val[i];
	}
	mx = max(mx, val[i]);
	mn = min(mn, val[i]);
	if (mx - mn + 1 == i - rec + 1 && mn == rec) cur = 0;
      } else {
	if (i != val[i]) {
	  puts("No");
	  return 0;
	}
      }
    }
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 1536
function Main(input) {
    input = input.split("\n");
  	var a = input[0].split(" ");
  	var b = input[1].split(" ");
  	var distance=parseInt(a[0],10);
  	var count=parseInt(a[1],10);
  	var num=[];
  	var array=[];
  	for(var i=0;i<count;i++){
		var pre=parseInt(b[i],10);
      	num.push(pre);
    }
  	var m=count-1
  	for(var j=0;j<m;j++){
      	var c=j+1;
      	var d=num[c]-num[j];
      	array.push(d);
    }
  	var last=distance+num[0]-num[m];
  	array.push(last);
  	function compareFunc(a, b) {
  return a - b;
}
array.sort(compareFunc);
  var total=0;
  	for(var l=0;l<m;l++){
      	total+=array[l];
    }
  console.log(total);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  int n,next;
  cin >> n;
  vector<int> a(n);
  vector<int> flag(n);
  
  for(int i=0; i<n; i++) cin >> a.at(i);
  
  next=1;
  int loop=0;
  while(true){
    loop++;
    next=a.at(next-1);
    if(next==2){
      cout << loop;
      break;
    }
    if(flag.at(next-1)==1){
      cout << -1;
      break;
    }
    flag.at(next-1)=1;
  }
  
}




Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vector<ld> p(n) ;
	for(auto &i:p) cin >> i ;
	vector<vector<ld>> dp(n+1,vector<ld>(n+1,0)) ;
	dp.at(0).at(0) = 1 ;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			dp.at(i).at(j) = dp.at(i-1).at(j)*(1-p.at(i-1)) ;
			if(j!=0) dp.at(i).at(j) += dp.at(i-1).at(j-1)*p.at(i-1) ;
		}
	}
	ld ans = 0 ;
	for(int j=0;j<=n;j++){
		if(j>n-j) ans += dp.at(n).at(j) ;
	}
	cout << fixed << setprecision(20) ;
	cout << ans << endl ;
}


Measured memory_bytes: 141056
# -*- coding: utf-8 -*-
def main():
    N,M = map(int,input().split())
    SC = [list(map(int,input().split())) for i in range(M)]
    ans = []
    anst = ''
    for _ in range(N):
        ans.append(-1)
    for j in range(M):
        if ans[SC[j][0]-1] == -1  or ans[SC[j][0]-1] == SC[j][1]:
            ans[SC[j][0]-1] = SC[j][1]
        else:
            print('-1')
            return
    for k in range(N):
        if ans[k] == -1:
            if k == 0 and N>=2:
                ans[k] = 1
            else:
                ans[k] = 0
        anst += str(ans[k])
    if len(str(int(anst))) != N:
        print('-1')
        return
    print(int(anst))
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
// C
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int n, h[maxn];
int main() {
    n = read();
    for (reg int i = 1; i <= n; i++) h[i] = read();
    reg int Ans = 0, res = 1;
    for (reg int i = 2; i <= n; i++) {
        if (h[i] <= h[i - 1]) res++;
        else Ans = max(Ans, res), res = 1;
    }
    Ans = max(Ans, res);
    cout << Ans - 1 << endl;
    return 0;
}


Measured memory_bytes: 640
A, B = list(map(int, input().split()))
if A > B:
    if A - 1 > B:
        print(A + A - 1)
    else:
        print(A + B)
elif B > A:
    if B - 1 > A:
        print(B + B - 1)
    else:
        print(A + B)
else:
    print(A + B)


Measured memory_bytes: 2940
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N;
  ll X;
  while (cin >> N >> X) {
    vector<ll> tot(N + 1), len(N + 1);
    tot[0] = len[0] = 1;
    for (int i = 1; i <= N; i++) {
      tot[i] = 2 * tot[i - 1] + 1;
      len[i] = 2 * len[i - 1] + 3;
    }
    function<ll(int, ll)> func = [&](int N, ll X) {
      if (N == 0) return X;
      if (X == 1) return 0ll;
      if (X == len[N]) return tot[N];
      if (X > len[N - 1] + 2) {
        return tot[N - 1] + 1 + func(N - 1, X - len[N - 1] - 2);
      }
      if (X == len[N - 1] + 2) {
        return tot[N - 1] + 1;
      }
      return func(N - 1, X - 1);
    };
    cout << func(N, X) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cmath>
using namespace std;

//num
#define EPS (1e-10)
#define INF (1e12);
//point
typedef complex<double> P;
#define X real()
#define Y imag()
double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
namespace std{
    bool operator < (const P& a, const P& b){
        return (a.X != b.X)? a.X < b.X : a.Y < b.Y;
    }
}
//line
struct L : vector<P> {
    L(P a, P b){
        push_back(a); push_back(b);
    }
};

//utility
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > 0) return +1; //counter clockwise
    if(cross(b,c) < 0) return -1; //clockwise
    if(dot(b,c) < 0) return +2; //c-a-b
    if(norm(b) < norm(c)) return -2; //a-b-c
    return 0; //a-c-b
}
//is_intersect
bool sameLL(const L& l, const L& m){
    double A = cross(l[1]-l[0], m[1]-m[0]);
    double B = cross(l[1]-l[0], l[1]-m[0]);
    return abs(A)<EPS && abs(B)<EPS;
}
bool intersectLL(const L& l, const L& m){
    return abs(cross(l[1]-l[0],m[1]-m[0])) > EPS || sameLL(l,m);
}
P crosspointLL(const L& l, const L& m){ //don't use the parallel case
    double A = cross(l[1] - l[0], m[1] - m[0]);
    double B = cross(l[1] - l[0], l[1] - m[0]);
    assert (abs(A) > EPS); //non parallel
    return m[0] + B / A * (m[1] - m[0]);
}


int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        vector<L> l;
        for(int i=0; i<n; i++){
            int x1,y1,x2,y2;
            cin >> x1 >> y1 >> x2 >> y2;
            l.push_back(L(P(x1,y1),P(x2,y2)));
        }

        int count = 1;
        for(int i=0; i<n; i++){
            vector<P> crosspoint;
            for(int j=0; j<i; j++){
                if(intersectLL(l[i],l[j])){
                    P cp = crosspointLL(l[i],l[j]);
                    if(cp.X < -100+EPS || cp.X > 100-EPS) continue;
                    if(cp.Y < -100+EPS || cp.Y > 100-EPS) continue;
                    bool isadd = true;
                    for(int k=0; k<(int)crosspoint.size(); k++){
                        if(norm(crosspoint[k]-cp) < EPS){
                            isadd = false;
                            break;
                        }
                    }
                    if(isadd){
                        crosspoint.push_back(cp);
                    }
                }
            }
            count += crosspoint.size()+1;
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int a, b;
  string op;
  cin >> a >> op >> b;
  if (op=="+") {
    cout << a+b << endl;
  }
  else {
    cout << a-b << endl;
  }
}


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

using namespace std;

char x[100005];
int n, lo = 1, hi, mi;
set< char > s;

int main() {
	scanf("%s", x);
	n = strlen(x);
	hi = n + 1;
	while (lo < hi) {
		mi = (lo + hi) / 2;
		s.clear();
		for (int i = n - mi; i < mi; i++)
			s.insert(x[i]);
		if (s.size() > 1)
			hi = mi;
		else
			lo = mi + 1;
	}
	printf("%d\n", lo - 1);
	return 0;
}

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

signed main() {
    int n;
    cin >> n;
    map<string, int> m;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << "\n";
     cout << "WA x " << m["WA"] << "\n";
     cout << "TLE x " << m["TLE"] << "\n";
     cout << "RE x " << m["RE"] << "\n";
}


Measured memory_bytes: 3632
n, h = map(int,input().split())
a = []
b = []
for i in range(n):
    ca, cb = map(int,input().split())
    a.append(ca)
    b.append(cb)

amax = max(a)
b.sort(reverse=True)
cnt = 0
bsum = 0
for i in range(n):
    if b[i] <= amax or bsum >= h:
        break
    else:
        bsum += b[i]
        cnt += 1
h -= bsum
if h > 0:
    cnt += h//amax
    h -= amax * (h//amax)
if h > 0:
    h -= amax
    cnt += 1
print(cnt)


Measured memory_bytes: 17260
n,m = map(int,input().split())
li = [list(map(int,list(input().split()))) for i in range(m)]
lip = list(map(int,input().split()))

cnt = 0
for i in range(2**n):
  s = format(i,"b").zfill(n)
  s = [int(x) for x in list(str(s))]
  for j in range(m):
    tmp = 0
    for k in range(li[j][0]):
      tmp += s[li[j][k+1]-1]
    if tmp % 2 != lip[j]:
      break
  else:
    cnt += 1
    continue
print(cnt)

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

using namespace std;

struct posi {
	int x;
	int y;
};

vector<posi> qposi;
vector<vector<bool>> dameposi(8, vector<bool>(8, false));
vector<vector<bool>> dameposiorg(8, vector<bool>(8, false));
vector<vector<bool>> candposi(8, vector<bool>(8, false));


void dameposisettei(int &posix, int &posiy) {
	vector<int> dx{ 1,-1,-1,1 };
	vector<int> dy{ 1,1,-1,-1 };

	for (int i = 0; i < 8; i++) {
		dameposi[posix][i] = true;
		dameposi[i][posiy] = true;
	}
	for (int j = 0; j < 4; j++) {
		int posixx = posix;
		int posiyy = posiy;
		posixx += dx[j];
		posiyy += dy[j];
		while (posixx >= 0 && posixx < 8 && posiyy >= 0 && posiyy < 8) {
			dameposi[posixx][posiyy] = true;
			posixx += dx[j];
			posiyy += dy[j];
		}
	}
}

vector<int> buf;
vector<bool> seen;
vector<string> ss;

void dfs(int i, const int size, const int range_start, const int range_end)
{
	if (i == size) {
		string str;
		// ここで所望の作業を行う
		for (int j = 0; j < buf.size(); j++) {
			//cout << buf[j];
			str.push_back((char)(buf[j] + 48));
		}
		//cout << endl;
		ss.push_back(str);

	}
	else {
		for (int j = range_start; j <= range_end; j++) {
			if (seen[j] == true) { continue; }

			seen[j] = true;
			buf[i] = j;

			dfs(i + 1, size, range_start, range_end);
			seen[j] = false;
		}
	}
}

void dameposidisp(void) {
	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			cout << dameposi[i][j];
		} 
		cout << endl;
	}
}
int main(void)
{
	int k;
	cin >> k;
	qposi.resize(k);

	for (int i = 0; i < k; i++) {
		cin >> qposi[i].x >> qposi[i].y;

		//dameposisettei(qposi[i].x, qposi[i].y);
	}

	dameposiorg = dameposi;


	//！！重複なし！！
	//range_start~~range_end、桁数sizeの組み合わせを作る
	//size：桁数
	//ss:組み合わせ結果の配列(string)

	int size = 8;
	int range_start = 0;
	int range_end = 7;

	buf.resize(size);
	seen.resize(range_end + 1);

	dfs(0, size, range_start, range_end);

	for (int i = 0; i < ss.size(); i++) {
		//if (ss[i][0] == '0') { continue; }
		//if (ss[i][1] == '0' || ss[i][1] == '1' || ss[i][1] == '2' || ss[i][1] == '3') { continue; }
		dameposi = dameposiorg;

		//dameposidisp();

//		cout << ss[i] << endl;
		bool brkflg = false;
		for (int j = 0; j < 8; j++) {
			int kk = ss[i][j]-'0';
			if (dameposi[j][ss[i][j] - '0'] == true) { 
				brkflg = true; 
				break; 
			}
			dameposisettei(j, kk);
			//dameposidisp();
		}

		if (brkflg == false) {
			for (int j = 0; j < k; j++) {
				if (ss[i][qposi[j].x]-'0' != qposi[j].y) { break; }
				if (j == k - 1) {
					for (int i1 = 0; i1 < 8; i1++) {
						for (int j1 = 0; j1 < 8; j1++) {
							if (ss[i][i1] - '0' == j1) {
								cout << 'Q';
							}
							else {
								cout << '.';
							}
						}
						cout << endl;
					}
					return 0;
				}
			}
		}
	}
	cout << ss.size();
	return 0;
}


Measured memory_bytes: 5148
#include<iostream>
using namespace std;
static const int MAX = 100;

int Bubblesort(int a[], int n)
{
	int flag = 1, i = 0;
	int res = 0;
	while (flag) {
		flag = 0;
		for (int j = n - 1;j > i;j--)
		{
			if (a[j] < a[j - 1])
			{
				int p = a[j - 1];
				a[j - 1] = a[j];
				a[j] = p;
				flag = 1;
				res++;
			}
		}
		i++;
	}
	return res;
}
int main()
{
	int n, a[MAX];
	cin >> n;
	for (int i = 0;i < n;i++)
	{
		cin >> a[i];
	}
	int res = Bubblesort(a, n);
	for (int i = 0;i < n;i++)
	{
		if (i > 0) cout << " ";
		cout << a[i];
	}
	cout << endl;
	cout << res<<endl;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(){
int x,a,b;cin>>x>>a>>b;
int m=abs(x-a),n=abs(x-b);
if(m<n)cout<<"A";
else cout<<"B";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if (s=="RRR")
  {
    cout<<"3"<<endl;
  }
  else if (s=="RRS")
  {
    cout<<"2"<<endl;
  }
  else if (s=="RSR")
  {
    cout<<"1"<<endl;
  }
  else if (s=="SRR")
  {
    cout<<"2"<<endl;
  }
  else if (s=="RSS")
  {
    cout<<"1"<<endl;
  }
  else if (s=="SRS")
  {
    cout<<"1"<<endl;
  }
  else if (s=="SSR")
  {
    cout<<"1"<<endl;
  }
  else
  {
    cout<<"0"<<endl;
  }
  return 0;
}
  

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

const int coin[4] = {10,50,100,500};
int cost,ans,a[4];
int ans_coin[4];

int check(int total){
  int res = 0;

  for(int i = 3 ; i >= 0 ; i--){
    res += total / coin[i];
    total %= coin[i];
  }

  return res;
}

void judge(){
  int ans = 1<<28;
  memset(ans_coin,0,sizeof(ans_coin));
  
  for(int i = 0 ; i <= a[0] ; i++){
    for(int j = 0 ; j <= a[1] ; j++){
      for(int k = 0 ; k <= a[2] ; k++){
	for(int l = 0 ; l <= a[3] ; l++){

	  int sum = coin[0]*i+coin[1]*j+coin[2]*k+coin[3]*l;
	  if(sum < cost) continue;

	  int want = sum - cost;
	  int tmp = check(want)-i-j-k-l;

	  if(tmp < ans){
	    ans_coin[0] = i; ans_coin[1] = j;
	    ans_coin[2] = k; ans_coin[3] = l;
	    ans = tmp;
	  }

	}
      }
    }
  }

}

int main(){  
  bool flg = false;
  while(cin >> cost ,cost){
    if(flg) cout << endl;
    for(int i = 0 ; i < 4 ; i++) cin >> a[i];
    judge();
    for(int i = 0 ; i < 4 ; i++){
      if(ans_coin[i]){
	cout << coin[i] << " " << ans_coin[i] << endl;
      }
    }
    flg = true;
  }

  return 0;
}

Measured memory_bytes: 1160
N = int(input())
A = list(map(int,input().split()))
S = [0]
for i in range(N):
    S.append(S[i]+A[i])
S.sort()
now = S[0]
s = 1
ans = 0
for i in range(1,N+1):
    if now == S[i]:
        s += 1
    else:
        ans += s*(s-1)//2
        s = 1
    now = S[i]
ans += s*(s-1)//2
print(ans)


Measured memory_bytes: 26716
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1LL << 60;

int main() {
  int n, k;
  cin >> n >> k;
  int h[100110];
  for (int i = 0; i < 100010; i++) cin >> h[i];

  ll dp[100110];
  for (int i = 0; i < 100010; i++) dp[i] = INF;

  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }

  cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1408
import sys
import math
from collections import deque
import heapq
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,K = IL()

used = [1]*N
for i in range(K):
  d = I()
  a = IL()
  for j in a:
    used[j-1] = 0

print(sum(used))

Measured memory_bytes: 68112
#include<stdio.h>

int main(){
  	int arr[32]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
   	scanf("%d",&k);
    printf("%d",arr[k-1]);
    return 0;
  
 return 0 ;
}


Measured memory_bytes: 128
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
# mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


def main():
    A, B, H, M = read_values()
    MM = H * 60 + M
    S = MM / (6 * 60) * math.pi
    T = M / 30 * math.pi
    print((A ** 2 + B ** 2 - 2 * A * B * math.cos(abs(S - T))) ** 0.5)


if __name__ == "__main__":
    main()



Measured memory_bytes: 10188
#include <iostream>
#include <vector>

using namespace std;

template<typename T>
void Print(const T* pArray, int size)
{
	for (int i = 0; i < size; ++i)
		cout << pArray[i] << (i != size - 1 ? " " : "\n");
}

template<typename T>
void InsertionSort(T* pArray, int size, int step, int& count)
{
	// [0]..[i][j]..[size - 1]
	for (int j = step; j <= size - 1; j++)
	{
		T value = pArray[j];
		int i = j - step;
		while (i >= 0 && pArray[i] > value)
		{
			pArray[i + step] = pArray[i];
			i -= step;
			++count;
		}

		pArray[i + step] = value;
	}
}

template<typename T>
void ShellSort(T* pArray, int size)
{
	vector<int> G;
	int h = 1;
	do
	{
		G.push_back(h);
		h = h * 3 + 1;
	} while (h < size);

	cout << G.size() << endl;
	for(int i = G.size() - 1; i >= 0; --i)
		cout << G[i] << (i != 0 ? " " : "\n");
	int count = 0;
	for (int i = G.size() - 1; i >= 0; --i)
		InsertionSort(pArray, size, G[i], count);
	cout << count << endl;
	for (int i = 0; i < size; ++i)
		cout << pArray[i] << endl;
}

int A[1000000];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> A[i];
	ShellSort(A, n);
	
	return 0;
}


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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	string s;
	cin >> s;
	reverse(all(s));
	cout << s << endl;
}

Measured memory_bytes: 1172