akhauriyash/Code-Regression huggingface dataset:
/*
    これって模擬本戦...？
 */

#include <cstdio>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int n;
map<string, int> products;
vector<string> names;

bool cmp(const string &a, const string &b) {
    if (a.length() != b.length()) return a.length() < b.length();
    return a < b;
}

int main() {
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        char buf[6];
        int num;
        string name;

        scanf(" %s", buf);
        scanf("%d", &num);
        name = string(buf);

        if (products.find(name) != products.end()) {
            products[name] += num;
        } else {
            products[name] = num;
        }

        names.push_back(name);
    }

    sort(names.begin(), names.end(), cmp);
    names.erase(unique(names.begin(), names.end()), names.end());

    for (int i=0; i<names.size(); i++) {
        printf("%s %d\n", names[i].c_str(), products[names[i]]);
    }
}

Measured memory_bytes: 1564
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int s,m=0;
  vector<int> a;
  bool flg[10000000];
  cin>>s;
  a.push_back(0);
  a.push_back(s);
  flg[s]=true;
  for(int i=2;m==0;i++){
    if(a[i-1]%2){
      a.push_back(3*a[i-1]+1);
      if(flg[3*a[i-1]+1]==true)m=i;
      flg[3*a[i-1]+1]=true;
    }else{
      a.push_back(a[i-1]/2);
      if(flg[a[i-1]/2]==true)m=i;
      flg[a[i-1]/2]=true;
    }
  }
  cout<<m<<"\n";
  return 0;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    string t;
    cin >> t;
    int n = sz(t);
    deque<char> s;
    for (char c : t) s.push_back(c);
    int q;
    cin >> q;
    int cnt = 0;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) cnt++;
        if (t == 2) {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1) {
                if (cnt & 1)
                    s.push_back(c);
                else
                    s.push_front(c);
            }
            if (f == 2) {
                if (cnt & 1)
                    s.push_front(c);
                else
                    s.push_back(c);
            }
            n++;
        }
    }
    if (cnt & 1)
        rrep(i, n) cout << s[i];
    else
        rep(i, n) cout << s[i];
    cout << endl;
}


Measured memory_bytes: 896
#include <iostream>

using namespace std;

int calc_ds(int i) {
    int ds=0;
    while(10*i/10) {
        ds += i%10;
        i /= 10; 
    }
    return ds;
}

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

    if(N%calc_ds(N)) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a < b) {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
		cout << endl;
	}
	else {
		for (int i = 0; i < a; i++) {
			cout << b;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
town = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]

for i in range(3):
    path = list(map(int,input().split()))
    town[path[0]-1][path[1]-1] = 1
    town[path[1]-1][path[0]-1] = 1

ans = 0
for i in town:
    cnt = 0
    for t in i:
        if t == 1:
            cnt += 1
    if cnt == 2:
        ans += 1
if ans == 2:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)round(x))<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

int h, w;
string t[1002], s[1002];
bool match[1002][1002];

bool matches(int sx, int sy){
  for(int x = sx; x < sx + 2; x++){
    for(int y = sy; y < sy + 2; y++){
      if(t[y][x] != s[y - sy][x - sx]){
        return false;
      }
    }
  }
  return true;
}

int main(void){
  while(cin >> h >> w){
    for(int i = 0; i < h; i++){
      cin >> t[i];
    }
    for(int i = 0; i < 2; i++){
      cin >> s[i];
    }

    memset(match, 0, sizeof(match));

    int cnt = 0;

    for(int i = 0; i < h - 1; i++){
      for(int j = 0; j < w - 1; j++){
        match[i][j] = matches(j, i);
        cnt += (int)match[i][j];
      }
    }

    int res = cnt;
    string joi = "JOI";

    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        char tmp = t[i][j];

        for(int k = 0; k < (int)joi.size(); k++){
          if(t[i][j] == joi[k]) continue;
          t[i][j] = joi[k];

          int diff = 0;

          for(int ti = i - 1; ti <= i; ti++){
            for(int tj = j - 1; tj <= j; tj++){
              if(ti < 0 || h - 1 <= ti) continue;
              if(tj < 0 || w - 1 <= tj) continue;
              if(match[ti][tj]){
                diff--;
              }
              else if(matches(tj, ti)){
                diff++;
              }
            }
          }

          res = max(res, cnt + diff);
        }

        t[i][j] = tmp;
      }
    }

    cout << res << endl;
  }
}

Measured memory_bytes: 3260
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <vector>

#include <bits/stdc++.h>
using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define TRUE (0)
#define FALSE (1)

// This value shold be close to used maximum value.  
#define NUM_MAX 20000000005

// void sort(uint32_t *num, uint32_t size);
int main()
{   
 
    vector<long long> vec(0);
    // vector<long long> res_vec(0);
    // uint64_t res_arr[NUM_MAX];
    // uint32_t sum = 0;
    uint64_t monster;
    uint64_t hissatsu;
    uint64_t result;
    uint64_t sum;

    // uint32_t res_i = 0;
    // string str_temp, str_temp2;
    uint64_t temp, temp2;
    uint64_t i, j, k, l, count, n, o, size;
    // uint32_t count = 0;
    // string str;
    // uint8_t k_flag;
 
    cin >> monster;
    count = 0;
    while (monster != 1) {
        monster = monster / 2;
        count++;
    }

    result = pow(2, count + 1) - 1;

    cout << result << endl;

    return 0;
}

// void sort(uint32_t *num, uint32_t size) {
//     uint32_t i, j, k;
//     uint32_t sorted_num;
//     uint32_t array[NUM_MAX] = {0};

//     for (i = 1; i < size + 1; i++) {
//         array[num[i - 1]]++;
//     }

//     sorted_num = 0;

//     for (i = 0; i < NUM_MAX; i++) {
//         for (j = 0; j < array[i]; j++) {
//             num[j + sorted_num] = i;
//         }
//         sorted_num += j;
//         j = 0;
//     }

//     return;
// }


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

int n,m,p;

int main()
{
	ios::sync_with_stdio(false);
	while(cin>>n>>m>>p){
		int t;
		double Min=1e9,x,s;
		for(int i=1;i<=n;++i)
		{
			cin>>x;
			s=m-x*0.006;
			if(abs(s-p)<Min){
				Min=abs(s-p);	t=i;
			}
		}
		cout<<t<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ( a + b > c + d ) {
        cout << "Left" << endl;
    }
    else if ( a + b < c + d ) {
        cout << "Right" << endl;
    }
    else {
        cout << "Balanced" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAX = 4001;

int dp[MAX][MAX];

int main(){
  string a,b;

  while(cin >> a >> b){
    int n = a.size(), m = b.size();
    int ans = 0;    

    memset(dp,0,sizeof(dp));

    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < m ; j++){
	if(a[i] == b[j]){
	  dp[i+1][j+1] = dp[i][j] + 1;
	}
	ans = max(ans,dp[i+1][j+1]);
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 63748
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll f[2];int a[55];
int main (){
	int n,p;
	scanf ("%d%d",&n,&p);
	for (int i=1;i<=n;i++)
	{scanf ("%d",&a[i]);a[i]&=1;}
	f[0]=1ll;
	f[1]=0ll;
	for (int i=1;i<=n;i++)
	{if (a[i]==0) {f[0]*=2ll;f[1]*=2ll;}
	else {ll t1=f[0],t2=f[1];f[0]+=t2;f[1]+=t1;}
	}
	printf ("%lld",f[p]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  long double a, b, c;
  cin >> a >> b >> c;
  
  if ( 4 * a * b < (c - a - b) * (c - a -b ) && (c - a - b) > 0) {
    cout << "Yes" << endl; 
  }
  else {
    cout << "No" << endl; 
  }
}


Measured memory_bytes: 256
gets
a = gets.chomp.split(' ').map(&:to_i)

min = nil
a.each do |n|
  count = 0
  while n % 2 == 0
    n /= 2
    count += 1
  end
  min = count if min.nil? || min > count
  break if min == 0
end

puts min


Measured memory_bytes: 3836
idx = lambda x: x-1
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in reversed(range(1, n+1)):
    cnt = 0
    for j in range(i*2, n+1, i):
        cnt += b[idx(j)]
    if cnt % 2 == a[idx(i)]: continue
    b[idx(i)] += 1
s = sum(b)
if s == 0:
    print(0)
    exit()
print(s)
for i in range(1, n+1):
    if b[idx(i)]: print(i)

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


void solve(long long N, long long K, std::string S){
  S.at(K - 1) = S.at(K - 1) - 'A' + 'a';
  cout << S << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::string S;
    std::cin >> S;
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    int cnt = 0;
    rep(i,n){
        int x; cin >> x; x--;
        if(i != x) cnt++;
    }
    if(cnt >= 3) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

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

    int n;cin >> n;
    vii x(n);
    vii y(n);
    rep(i,n){
        int p;cin >> p;
        rep(j,p){
            int tx,ty;cin >> tx >> ty;
            x[i].push_back(tx);
            y[i].push_back(ty);
        }
    }

    int ans = 0;
    for(int bit=1;bit<(1<<n);bit++){
        bool flag = true;
        for(int i=0;i<n;i++){
            if((1<<i) & bit){
                for(int j=0;j<x[i].size();j++){
                    if(y[i][j] ^ (bit>>(x[i][j]-1) & 1) )flag = false;
                    if(!flag)break;
                }
            }
            if(!flag)break;
        }
        if(flag)chmax(ans,(int)bitset<15>(bit).count());
    }
    cout << ans << endl;
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

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

  vector<ll> x(n), y(n), z(n);
  rep (i, n) cin >> x[i] >> y[i] >> z[i];

  ll ans = 0;
  rep (bit, (1 << 3)) {
    vector<ll> sum;
    rep (i, n) {
      ll tmp = 0;
      tmp += x[i] * (bit & 1 ? -1 : 1);
      tmp += y[i] * (bit & 2 ? -1 : 1);
      tmp += z[i] * (bit & 4 ? -1 : 1);
      sum.eb(tmp);
    }

    sort(rall(sum));

    ll v = 0;
    rep (i, m) v += sum[i];

    ans = max(ans, v);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>
 
using namespace std;
using experimental::any;
 
#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
 
#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
#define BitFOR(N) REP(Bit,1<<(N))
 
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) (f)? cout<<"true ":cout<<"false ";
#define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X)
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define ARDEB(i,X) {}
#define TFDEB(f) {}
#define FORDEB(n,X) {}
#define END {}
#endif
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};
struct P2{int x,y;};
#define BIT(Bit,n) bitset<n>(Bit)
#define Endl endl
 
const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000;

int N,M[2][110],D[2][110];

int main(){
	int n,a[100][100],ans=0;
	cin>>n;
	REP(i,2)REP(j,n){
		cin>>a[i][j];
	}
	for(int i=0;i<n;i++){
		int sum=0,sum2=0;
		for(int j=0;j<=i;j++){
			sum+=a[0][j];
		}
		for(int j=i;j<n;j++){
			sum2+=a[1][j];
		}
		ans=max(ans,sum+sum2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int a,b,c,ab,ac;
	cin>>a>>b>>c;
	ab=abs(a-b);
	ac=abs(a-c);
	if(ab<ac) puts("A");
	else puts("B");
    return 0;
}

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

LL int dp[105][100010], v[111], w[111];

int main(){
    int n, W;
    cin >> n >> W;
    for(int i = 1; i <= n ; i++){
        cin >> w[i] >> v[i];
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= W; j++){
            dp[i][j] = dp[i-1][j];
            if(w[i] <= j){
                dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
            }
        }
    }
    cout << dp[n][W] << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<string> S(N);
  for (int i=0; i<N; i++) {
    cin >> S.at(i);
  }
  
  int M;
  cin >> M;
  
  vector<string> T(M);
  for (int i=0; i<M; i++) {
    cin >> T.at(i);
  }
  
  int score=0;
  
  for (int i=0; i<N; i++) {
    int a=0;
    
    for (int j=0; j<N; j++) {
      if (S.at(i) == S.at(j)) {
        a++;
      }
    }
    
    for (int j=0; j<M; j++) {
      if (S.at(i) == T.at(j)) {
        a--;
      }
    }
    
    if (a > score) {
      score = a;
    }
  }
  
  cout << score << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<deque>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include<string>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

int n, k;
vector<int> h;
vector<int> c;

int cost_i2j(int i, int j) {
	return abs(h[j] - h[i]);
}

int main(void) {
	cin >> n >> k;
	h.resize(n + 1);
	c = vector<int>(n + 1, 0);
	for (int i = 1; i < n + 1; i++)
		cin >> h[i];

	for (int i = 2; i < n + 1; i++) {
		int tmp = c[i-1] + cost_i2j(i-1, i);
		for (int j = 2; j < min(i, k+1); j++)
			tmp = min(tmp, c[i - j] + cost_i2j(i - j, i));
		c[i] = tmp;
	}
	cout << c[n] << endl;
	return 0;
}

Measured memory_bytes: 3976
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
if sum(A) < sum(B):
  print(-1)
  exit()

D = []
for i in range(N):
  D += [A[i]-B[i]]
D.sort()
M = 0
for i in range(N):
  if D[i] < 0:
    M += D[i]
    ans += 1
  else:
    break
for i in reversed(range(N)):
  if M >= 0:
    print(ans)
    break
  else:
    M += D[i]
    ans += 1


Measured memory_bytes: 24240
import sys, math
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

@lru_cache(maxsize=None)
def f(n):
    if n == 0:
        return 1
    res = 0
    for i in range(n-2):
        res += f(i)
    return (res)%MOD
    

def main():
    S = ii()
    print(f(S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9620
import java.util.*;

class Main {
  public static void main (String[] args) throws java.lang.Exception {
    Scanner scanner = new Scanner(System.in);
    String argument = scanner.next();
    boolean result = ATCoder_abc159_b.isStrongPalindrome(argument);
    System.out.printf("%s\n", result ? "Yes" : "No");
  }
}

class ATCoder_abc159_b {
	public static boolean isStrongPalindrome(String argument) {
		char[] argumentChars = argument.toCharArray();
		int halfwayLength = (argumentChars.length-1 ) / 2;
		int fullLength = argumentChars.length;
		for (int pos=0; pos < halfwayLength; ++pos) {
			// String must be a palindrome
			if (argumentChars[pos] != argumentChars[fullLength-pos-1]) {
				return false;
			}
			// First 'half' of string must be a palindrome
			if (argumentChars[pos] != argumentChars[halfwayLength-pos-1]) {
				return false;
			}
		}
		return true;
	}
}


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

int main(void)
{
    int H, W;
    cin >> H >> W;
    char S[H][W];

    int vx[] = {1, -1, 0, 0};
    int vy[] = {0,
                0,
                1,
                -1};

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
            cin >> S[i][j];
    }
    string ans = "Yes";
    int x, y;
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
        {
            if (S[i][j] == '#')
            {
                bool flg = false;
                for (int k = 0; k < 4; k++)
                {
                    x = i + vx[k];
                    y = j + vy[k];
                    if (x >= 0 && x < H && y >= 0 && y < W)
                    {
                        if (S[x][y] == '#')
                            flg = true;
                    }
                }
                if (!flg)
                    ans = "No";
            }
        }
    cout << ans << endl;

    return 0;
}

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

int f[1000001];
int main(){
    fill_n(f,1000001,1);
    f[0]=f[1]=0;
    
    for(int i=2;i<1000001;i++){
        f[i]+=f[i-1];
        if(!f[i])continue;
        for(int j=i+i;j<1000001;j+=i)f[j]=0;
    }
    
    int N;
    
    while(scanf("%d",&N)!=EOF){
        printf("%d\n",f[N]);
    }
    
    return 0;
    
}

Measured memory_bytes: 5092
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::iter::once;
#[cfg(debug_assertions)]
include! {"./debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

macro_rules! read {
    ([$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ([$t:ident]) =>
        (rl().split_whitespace().map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    (_, [$t:ident] ; $n:expr) =>
        ((0..$n).map(|_| read!(_, [$t])).collect::<Vec<_>>());
    (_, [$t:ident]) =>
        (rl().split_whitespace().skip(1).map(|w| read_type!(w, $t)).collect::<Vec<_>>());
    ($($t:ident),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ($t:ident) => (read_type!(rl(), $t));
    ($($t:ident),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(read_type!(w.next().unwrap(), $t)),*)
    }};
}

macro_rules! read_type {
    ($s:expr, chars) => {
        $s.chars().collect::<Vec<char>>()
    };
    ($s:expr, usize1) => {
        read_type!($s, usize) - 1
    };
    ($s:expr, $t:ty) => {
        $s.parse::<$t>().unwrap()
    };
}

fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

////////////////////////////////////////////////////////////////////////////////

fn main() {
    let (n, d) = read!(usize, usize);
    let x = read!([i64]; n);

    let ans: usize = x
        .iter()
        .map(|ref v1| {
            x.iter()
                .map(|ref v2| {
                    debug!(v1, v2);
                    v1.iter()
                        .zip(v2.iter())
                        .map(|(&y, &z)| (y - z) * (y - z))
                        .fold(0, |sum, i| sum + i)
                })
                .filter(|&x| x != 0)
                .filter(|&x| {
                    let a = (x as f64).sqrt();
                    debug!(a);
                    a == a.floor()
                })
                .count()
        })
        .sum();

    println!("{}", ans / 2);
}


Measured memory_bytes: 4352
from collections import deque
N, Q = map(int, input().split())
pathes = []
for _ in range(N-1):
    a, b = map(int, input().split())
    pathes.append((a, b))
childs = [[] for i in range(N+1)]
for a, b in pathes:
    childs[a].append(b)
    childs[b].append(a)
cnt = [0]*(N+1)
for _ in range(Q):
    p, x = map(int, input().split())
    cnt[p] += x
closed = [False]*(N+1)
nodes = deque()
nodes.append(1)
while len(nodes) != 0:
    node = nodes.popleft()
    closed[node] = True
    for c in childs[node]:
        if closed[c]:
            continue
        nodes.append(c)
        cnt[c] += cnt[node]
for i in range(1, N+1):
    print(cnt[i])

Measured memory_bytes: 69388
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <tuple>
#include <deque>
using namespace std;

typedef pair<int,int> P;//駅id,会社id(0は改札外)
map<P,map<P,int>> G;//エッジリスト(キモい)
map<P,int> memo;
const int INF = 1000000000;
typedef tuple<int,int,int> T;//cost,駅id,会社id
//priority_queue<T,vector<T>,greater<T>> que;
deque<T> que;
//#define mygc(c) (c)=getchar_unlocked()
//void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;} }for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}

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

    int N,M;
    cin>>N>>M;
    //reader(&N); reader(&M);
    for(int i=1;i<=N;i++) memo[P(i,0)]=INF;
    for(int i=0;i<M;i++){
        int p,q,c;
        cin>>p>>q>>c;
        //reader(&p); reader(&q); reader(&c);
        G[P(p,c)][P(q,c)]=0;
        G[P(p,c)][P(p,0)]=0;
        G[P(p,0)][P(p,c)]=1;
        G[P(q,c)][P(p,c)]=0;
        G[P(q,c)][P(q,0)]=0;
        G[P(q,0)][P(q,c)]=1;
        memo[P(p,c)]=memo[P(q,c)]=INF;
    }
    memo[P(1,0)]=0;
    //que.emplace(0,1,0);
    que.emplace_back(0,1,0);
    while(!que.empty()){
        //T t = que.top(); que.pop();
        T t = que.front(); que.pop_front();
        int cost=get<0>(t), station=get<1>(t), company=get<2>(t);
        if(station==N){
            cout<<cost<<endl;
            return 0;
        }
        if(cost>memo[P(station,company)]) continue;
        for(auto &g:G[P(station,company)]){
            const P &p = g.first; int fee=g.second;
            if(cost+fee<memo[p]){
                memo[p]=cost+fee;
                //que.emplace(cost+fee,p.first,p.second);
                if(fee){
                    que.emplace_back(cost+fee,p.first,p.second);
                }else{
                    que.emplace_front(cost+fee,p.first,p.second);
                }
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}

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


def solve(N: int, X: "List[int]"):
    # 最小
    import math

    ans = 999999999
    for p in range(1, 100 + 1):
        vit = 0
        for x in X:
            vit += pow((x - p), 2)
        ans = min(ans, vit)
    print(ans)
    return


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

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
//????????????????????????????¨?
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		
		String serchWord = br.readLine().toLowerCase();
		
		int cnt = 0;
		boolean flg = true;
		String endWord ="END_OF_TEXT";
		
		while(flg){
			
			String[] sentence = br.readLine().split(" ");		
			
			for(int i=0; i<sentence.length; i++) {
				if(sentence[i].toLowerCase().equals(serchWord)) {
					cnt = cnt + 1;
				}
				else if(sentence[i].equals(endWord)) {
					flg = false;
				}
			}
		}
		System.out.println(cnt);
	}
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

bool cp(int n)
{
    if(n<2)
        return 0;

    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n;
    cin>>n;

    for(int i=n;;i++)
    {
        if(cp(i))
        {
            cout<<i;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <string.h>
char* myfgets(char *buf,int n,FILE *fp){ //accepts LF/CRLF
	char *ret=fgets(buf,n,fp);
	if(!ret)return NULL;
	if(strlen(buf)&&buf[strlen(buf)-1]=='\n')buf[strlen(buf)-1]=0;
	if(strlen(buf)&&buf[strlen(buf)-1]=='\r')buf[strlen(buf)-1]=0;
	return ret;
}

char Q[29999];
char *q[9];
char L[99999];
int ind[9];
int n;
dfs(depth){
	int cur_ind=0;
	if(!myfgets(L,sizeof(L),stdin)){puts("no such property");exit(0);}
	if(depth){
		for(;L[cur_ind]==' ';cur_ind++);
		if(ind[depth-1]>=cur_ind){puts("no such property");exit(0);}
	}
	char *name=strtok(L+cur_ind,":"),*value=name+strlen(name)+1;
	if(!strcmp(name,q[depth])){
		if(depth==n-1){
			if(*value)
				printf("string \"%s\"\n",value+1),exit(0);
			else
				puts("object"),exit(0);
		}
		ind[depth]=cur_ind;
		dfs(depth+1);
	}
	dfs(depth);
}

main(depth){
	myfgets(Q,sizeof(Q),stdin);
	q[0]=strtok(Q+1,".");
	for(n=1;;n++)if(!(q[n]=strtok(NULL,".")))break;
	dfs(0);
}

Measured memory_bytes: 588
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=110,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

char s[N][N];
int f[N][N],n,m;

int main() {
	qr(n); qr(m); memset(f,63,sizeof f);
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	f[1][1]=(s[1][1]=='#');
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++)
			f[i+1][j]=min(f[i+1][j],f[i][j]+(s[i][j]!=s[i+1][j])),
			f[i][j+1]=min(f[i][j+1],f[i][j]+(s[i][j]!=s[i][j+1]));
	}
	pr2(f[n][m]+1>>1);
	return 0;
}



Measured memory_bytes: 256
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    S = single_input()
    YYMM = False
    MMYY = False
    if 1 <= int(S[2:]) <= 12: YYMM = True
    if 1 <= int(S[:2]) <= 12: MMYY = True

    if YYMM and MMYY: print("AMBIGUOUS")
    elif YYMM: print("YYMM")
    elif MMYY: print("MMYY")
    else: print("NA")
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
 
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    cout<<b<<a;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }
        int total = 0;
        for (int i = 0 ; i < n ; i++ ) {
            total += a[i] - 1;
        }
        System.out.println(total);
    }
    }


Measured memory_bytes: 26856
#include<stdio.h>
int main(){
    int h[10000],w[10000],i,j,n,m;
    i=0;
    while(1){
        scanf("%d %d",&h[i],&w[i]);
        if(h[i]==0&&w[i]==0){
            break;
        }
        i++;
    }
    for(j=0;j<i;j++){
        for(n=0;n<h[j];n++){
            for(m=0;m<w[j];m++){
                if((m==0)||(m==w[j]-1)){
                    printf("#");
                }
                else if((n==0)||(n==h[j]-1)){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#define llint long long

using namespace std;

llint h, w, m;
char map[55][55];
vector<llint> vec[55][55];
bool used[55][55];
const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
llint a[55][55], b[55][55], c[55][55];

llint dfs(llint x, llint y, llint gx, llint gy, llint px, llint py, llint t)
{
	if(x == gx && y == gy){
		vec[x][y].push_back(t);
		return 0;
	}
	llint nx, ny;
	for(int i = 0; i < 4; i++){
		nx = x + dx[i], ny = y + dy[i];
		if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
		if(map[nx][ny] == '#') continue;
		if(nx == px && ny == py) continue;
		llint res = dfs(nx, ny, gx, gy, x, y, t+1);
		if(res >= 0){
			vec[x][y].push_back(t);
			return res+1;
		}
	}
	return -1;
}

int main(void)
{
	cin >> h >> w >> m;
	for(int y = 0; y < h; y++){
		for(int x = 0; x < w; x++){
			cin >> map[x][y];
		}
	}
	for(int y = 0; y < h; y++){
		for(int x = 0; x < w; x++){
			cin >> a[x][y];
		}
	}
	for(int y = 0; y < h; y++){
		for(int x = 0; x < w; x++){
			cin >> b[x][y];
		}
	}for(int y = 0; y < h; y++){
		for(int x = 0; x < w; x++){
			cin >> c[x][y];
		}
	}
	
	llint x, y, gx, gy, t = 0;
	cin >> y >> x;
	for(int q = 0; q < m; q++){
		cin >> gy >> gx;
		t += dfs(x, y, gx, gy, -1, -1, t);
		x = gx, y = gy;
	}
	
	llint ans = 0;
	for(int x = 0; x < w; x++){
		for(int y = 0; y < h; y++){
			if(vec[x][y].size() == 0) continue;
			for(int i = 1; i < vec[x][y].size(); i++){
				ans += min(b[x][y]+c[x][y], (vec[x][y][i]-vec[x][y][i-1])*a[x][y]);
			}
			ans += b[x][y]+c[x][y];
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 13400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, x = 0;
  cin >> N;
 
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    x += B - A + 1;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    bool prime[110000];
    for(int i=0;i<110000;i++)prime[i]=true;
    prime[0]=prime[1]=false;
    for(int i=0;i<1005;i++){
        if(prime[i]){
            for(int j=i*2;j<110000;j+=i)prime[j]=false;
        }
    }
    int a[10000],point=0;
    for(int i=2;i<110000;i++){
        if(prime[i]){
            a[point++]=i;
        }
        if(point>=10000)break;
    }
    int n;
    while(cin>>n,n){
        int sum=0;
        for(int i=0;i<n;i++)sum+=a[i];
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 1304
#include <iostream>
#include <vector>
#include <string>
#include<map>
using namespace std;

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

    int result500;
    int result5;

    result500 = X / 500;
    X = X - result500 * 500;
    result5 = X / 5;
    int happy = result500 * 1000 + result5 * 5;
    cout << happy << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>

using namespace std;

int main(){

    int n;
    cin >> n;
    long long x[n], y[n];
    long long p, q;
    for(int i=0;i<n;i++)cin >> x[i] >> y[i];

    unsigned long long ans = 0;



    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)continue;
            unsigned long long tmp = 0;
            for(int k=0;k<n;k++){
                for(int l=0;l<n;l++){
                    if(k==l)continue;
                    if(x[i]-x[j]==x[k]-x[l] && y[i]-y[j]==y[k]-y[l])tmp++;
                }
            }
            ans = max(ans, tmp);
        }
    }

    cout << n-ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    ll N,A,B;cin>>N>>A>>B;
    ll ans=N/(A+B)*A;
    ans+=min(N%(A+B),A);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
x=int(input())
a=input().split()
j=0
while j<x :
    a[j]=int(a[j])
    j=j+1
i=0
while i<x :
    k=0
    while k<(x-1) :
        if a[k]>a[k+1] : 
            tmp=a[k]
            a[k]=a[k+1]
            a[k+1]=tmp
        k=k+1
    i=i+1
mx=int(a[x-1])
mn=int(a[0])
if (mx-mn)%2>0 : ans=(mx-mn)//2+1
else : ans=(mx-mn)/2
print(int(ans))


Measured memory_bytes: 5616
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
  	"math"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var transport []int
	personNum, _ := strconv.Atoi(nextLine())
	for i := 0; i < 5; i++ {
		num , _ := strconv.Atoi(nextLine())
		transport = append(transport, num)
	}
	sort.Sort(sort.IntSlice(transport))
    v := float64(personNum)/float64(transport[0])
	fmt.Println(int(math.Ceil(v))+4)
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;


int main(){
    for(;;){
        int n,q;
        cin >> n >> q;
        if(!n and !q) break;
        vector<int> sca(101,0);
        for (int i=0; i<n;i++) {
            int m;
            cin >> m;
            for (int j=0; j<m; j++) {
                int p;
                cin >> p;
                sca[p]++;
            }
        }
        int ans = 0;
        for (int i=0; i<101; i++) {
            if(sca[ans]<sca[i]) ans = i;
        }
        if (sca[ans] >= q) {
            cout << ans <<endl;
        }else{
            cout << 0 <<endl;
        }
    }
}

Measured memory_bytes: 1196
N = int(input())
a = list(map(int,input().split()))
S = a[0]
for i in range(1,N):
  S = S^a[i]
b = [0 for _ in range(N)]
for i in range(N):
  b[i] = S^a[i]
  
print(" ".join(map(str,b)))

Measured memory_bytes: 41756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
const int MAX = 1e5+10;
const double exps = 1e-8;

inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }

int main () {
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a*b)/2;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	ss := make([]string, n)
	m := make(map[string]int, n)
	r := 0
	for i := range ss {
		fmt.Scan(&ss[i])
		ss[i] = SortString(ss[i])
		_, ok := m[ss[i]]
		if ok {
			m[ss[i]]++
			r += m[ss[i]]
		} else {
			m[ss[i]] = 0
		}
	}
	fmt.Println(r)
}
func SortString(w string) string {
	s := strings.Split(w, "")
	sort.Strings(s)
	return strings.Join(s, "")
}


Measured memory_bytes: 13568
S = input()

result = 0
result2 = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] != "0":
            result += 1
        else:
            result2 += 1
    else:
        if S[i] != "1":
            result += 1
        else:
            result2 += 1

print(min(result, result2))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int H, W;
int imos1[2222][2222], imos2[2222][2222];

int main()
{
    cin >> H >> W;
    vector<string> s(H);

    for (int i = 0; i < H; i++)
        cin >> s[i];

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (s[i][j] == '.')
                imos1[i + 1][j + 1]++, imos1[i + 1][j + 1] += imos1[i + 1][j];
        }

        for (int j = W; j > 0; j--)
        {
            if (imos1[i + 1][j] > 0)
                imos1[i + 1][j] = max(imos1[i + 1][j + 1], imos1[i + 1][j]);
        }
    }

    for (int i = 0; i < W; i++)
    {
        for (int j = 0; j < H; j++)
        {
            if (s[j][i] == '.')
                imos2[j + 1][i + 1]++, imos2[j + 1][i + 1] += imos2[j][i + 1];
        }

        for (int j = H; j >= 0; j--)
        {
            if (imos2[j][i + 1] > 0)
                imos2[j][i + 1] = max(imos2[j + 1][i + 1], imos2[j][i + 1]);
        }
    }

    int ans = 0;
    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            ans = max(ans, imos1[i][j] + imos2[i][j] - 1);
        }
    }
    cout << ans << endl;
}

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

signed main(){
  int A,B,N,ans=0;
  cin>>A>>B>>N;
  A=abs(A);
  int ne=A%N,cons=B-A/N;
  if(abs(ne-A)/N>B){
    ans=(A-B*N);
    cout<<ans<<endl;
    return 0;
  }
  if(cons%2==1){
    ans=min(ne+N,abs(ne-N));
  }else{
    ans=ne;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    string s; cin>>s;

    vint sum(N+1);
    for(int i=1;i<=N;i++){
        sum[i]=sum[i-1]+(s[i-1]=='E');
    }
    
    int ans=N;
    for(int i=1;i<=N;i++){
        int num=(i-1)-sum[i-1]+sum[N]-sum[i];
        ans=min(ans,num);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N;
  cin >> N;
  vector <int> V(N);
  vector <int> C(N);
  rep(i,N) cin >> V[i];
  rep(i,N) cin >> C[i];

  vector <int> X(N);  //V_i - C_i 価値とコストの差
  rep(i,N) X[i] = V[i] - C[i];

  int ans = 0;
  rep(i,N){
    if (X[i] > 0) ans += X[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    ll N, num = 0, count = 0;
    cin >> N;

    count += (N / 11) * 2;
    if(N % 11 > 6) count += 2;
    else if(N % 11 > 0) count++;

    cout << count << endl;
}

Measured memory_bytes: 3624
N = int(input())
if N <= 9:
    ans = N
elif N <= 99:
    ans = 9
elif N <= 999:
    ans = N - 90
elif N <= 9999:
    ans = 909
elif N <= 99999:
    ans = N - 9090
else:
    ans = 90909
print(ans)

Measured memory_bytes: 2940
#include <iostream>

using namespace std;
int a, b, c;
int sum(int, int, int);
int main()
{
	cin >> a;
	cin >> b;
	cin >> c;
	sum(a, b, c);
	cout << sum(a, b, c) << endl;
	return 0;
}

int sum(int a, int b, int c)
{
	int d, e, f;
	d = a - b;
	e = d / c;
	f = d - (c * e);
	return f;
}

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

int findSumOfDigits(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int N;
    cin >> N;
    int f_N = findSumOfDigits(N);
    if (N % f_N == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var a = Number(inputs[0]);
    var b = Number(inputs[1]);
    var c = Number(inputs[2]);
    if (a<b && b<c){
    	console.log('Yes');
    }else {
    	console.log('No');
    }
  
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15504
#include <stdio.h>
#define N 8
#define NOTFREE -1
#define FREE 1

int r,c;
int k[N][N],row[N],col[N],dpos[15],dneg[15];

void putQueen(int i){
  int j;

  if( i == N ){
    printBoard();
    return;
  }

  for( j = 0; j < N; j++){
    if(col[j]==NOTFREE||dpos[i+j]==NOTFREE||dneg[i-j+N-1]==NOTFREE) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOTFREE;
    putQueen(i+1);
    col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
} 

void printBoard(void){
  int i,j;

  for( i = 0; i < N; i++){
    for( j = 0; j < N; j++){
      if( k[i][j] == NOTFREE && row[i] != j) return;
    }
  }

  for( i = 0; i < N; i++){
    for( j = 0; j < N; j++){
      if( row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

int main() {
  int i,j,n;

  for( i = 0; i < N; i++){
    row[i]=FREE;
    col[i]=FREE;
    for( j = 0; j < N; j++){
      k[i][j]=0;
    }
  }
  for( i = 0; i < 15; i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&r,&c);
    k[r][c] = NOTFREE;
  }

  putQueen(0);

  return 0;
}

Measured memory_bytes: 572