akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,K; cin>>N>>K;
    int g=0,M=0;
    REP(i,N){
        int a; cin>>a;
        g=__gcd(g,a);
        M=max(M,a);
    }
    if(K<=M and K%g==0) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}


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

int main() {
    int A, B, K;
    set<int> setk;
    cin >> A >> B >> K;

    for (int i=A; i<min(A+K, B+1); i++) setk.insert(i);
    for (int i=B; i>max(B-K, A-1); i--) setk.insert(i);
    for (auto si:setk) cout << si << endl;

    return 0;
}



Measured memory_bytes: 256
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
n=int(input())
l = [list(map(int, input().split())) for _ in range(n)]
import numpy as np
y=np.zeros(9).reshape(3,3)
for i in range(n):
    for x in range(3):
        if a[x]==l[i][0]:
            y[0][x]=1
for i in range(n):
    for x in range(3):
        if b[x]==l[i][0]:
            y[1][x]=1
for i in range(n):
    for x in range(3):
        if c[x]==l[i][0]:
            y[2][x]=1
if sum(y[0])==3:
    print('Yes')
elif sum(y[1])==3:
    print('Yes')
elif sum(y[2])==3:
    print('Yes')
elif sum(y[1])==3:
    print('Yes')
elif y[0][0]+y[1][0]+y[2][0]==3:
    print('Yes')
elif y[0][1]+y[1][1]+y[2][1]==3:
    print('Yes')
elif y[0][2]+y[1][2]+y[2][2]==3:
    print('Yes')
elif y[0][0]+y[1][1]+y[2][2]==3:
    print('Yes')
elif y[0][2]+y[1][1]+y[2][0]==3:
    print('Yes')
else:
    print('No')

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

typedef long long ll;

int main(){
  ll k;
  cin >> k;
  cout << 50 << endl;
  ll count=k/50,t=k%50;
  ll ans[50];
  for(int i=0;i<t;i++){
    ans[i]=count+100-t;
  }
  for(int i=t;i<50;i++){
    ans[i]=count+49-t;
  }
  for(int i=0;i<50;i++){
    cout << ans[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
//   ┏━━┓┏━━┓┏┓┏┓┏┳━┳┓┏━━┓┏━┳┓┏━━┓     ┏┳┓┏┳┓┏━┳━┓┏━━┓┏━┓
//   ┃┏┓┃┃━━┫┃┗┛┃┃┃┃┃┃┃┏┓┃┃┃┃┃┗┃┃┛     ┃┏┛┃┃┃┃┃┃┃┃┃┏┓┃┃╋┃
//   ┃┣┫┃┣━━┃┃┏┓┃┃┃┃┃┃┃┣┫┃┃┃┃┃┏┃┃┓     ┃┗┓┃┃┃┃┃┃┃┃┃┣┫┃┃┓┫
//   ┗┛┗┛┗━━┛┗┛┗┛┗━┻━┛┗┛┗┛┗┻━┛┗━━┛     ┗┻┛┗━┛┗┻━┻┛┗┛┗┛┗┻┛
#include "bits/stdc++.h" 
using namespace std; 
#define mod 1e9 + 7 
#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++) 
#define FORL(a, b, c) for (int(a) = (b); (a) < (c); (a)++) 
#define FORR(a, b, c) for (int(a) = (b); (a) > (c); (a)--) 
typedef long long int ll; 
typedef vector<int> vi; 
typedef pair<int, int> pi; 
#define PB push_back 
#define POB pop_back 
#define MP make_pair 
int main() 
{ 
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int n,x,t;
  cin>>n>>x>>t;
  ll a = n/x;
  if(n%x==0){
    a+=0;
  }
  else{
    a+=1;
  }
  cout<< a*t;
}
// By Ashwani Kumar, Indian Institute Of Technology(IIT), Guwahati.
//   ╔══╗╔══╗╔══╗     ╔══╗╔╦╗╔╦═╦╗╔══╗╔╗╔╗╔══╗╔══╗╔══╗
//   ╚║║╝╚║║╝╚╗╔╝     ║╔═╣║║║║║║║║║╔╗║║╚╝║║╔╗║╚╗╔╝╚║║╝
//   ╔║║╗╔║║╗─║║─     ║╚╗║║║║║║║║║║╠╣║║╔╗║║╠╣║─║║─╔║║╗
//   ╚══╝╚══╝─╚╝─     ╚══╝╚═╝╚═╩═╝╚╝╚╝╚╝╚╝╚╝╚╝─╚╝─╚══╝

Measured memory_bytes: 3636
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  string S;
  cin >> S;

  rep(i, 3) {
    cout << S[i];
  }
  cout << endl;
}


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

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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public static int count(int a , int b){
            int v = 0;
            while(a > 1){
                if (a % b == 0){
                    v++;
                    a/=b;
                }
                else break;
            }
            return v;


        }
        public void solve(int testNumber , InputReader in , PrintWriter out){
            int n = in.nextInt();
            long ans = 1;
            boolean[] arr = new boolean[n+1];
            for (int i = 2; i <=n ; i++) {
                arr[i]=true;
            }
            for (int i = 2; i <= n ; i++) {
                if (arr[i]){
                    int v = 2;
                    for (int j = i+i; j <=n ; j+=i) {
                        v+=count(j , i);
                        arr[j]=false;

                    }
                    ans*=v;
                    ans%=1000000000+7;
                }
            }
            out.println(ans%(1000000000+7));





        }
    }

    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: 21460
#include<iostream>

using namespace std;

int main()
{char A; cin >> A;
 if(A == 'a' || A == 'i' || A == 'u' || A == 'e' || A == 'o')
 {cout << "vowel"<<endl;}
else{cout << "consonant" << endl;}
 
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long int
#define fr(i,n) for(ll i=0; i<n; i++)
#define fre(i,n) for(ll i=1; i<=n; i++)
#define pb push_back
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define pii pair<ll,ll>
#define ve vector
#define piii pair<pii, ll>
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;


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

    long long int cost[n], a[n];

    fr(i, n) cin>>a[i];
    cost[0] = 0;

    for(int i=1; i<n; i++){
        int x = (i-1>=0)?abs(a[i]-a[i-1])+cost[i-1]:10000000000000;
        int y = (i-2>=0)?abs(a[i]-a[i-2])+cost[i-2]:10000000000000;
        cost[i] = min(x, y);
    }
    cout<<cost[n-1]<<endl;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();
      int k = sc.nextInt();
      int[] data = new int[n];
      int sum = 0;

      for(int i = 0;i<n;i++){
        data[i] = sc.nextInt();
      }
      Arrays.sort(data);

      for(int i = n-1;i>n-1-k;i--){
        sum = sum + data[i];
      }

      System.out.println(sum);

  }
}


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

const int inf = 1e9 + 13;

void ckmin (int &x, int a) {
	x = min(x, a);
}

signed main () {
	int n, m;
	cin >> n >> m;
	vector < int > a(m + 1), c(m + 1, 0);
	for (int i = 1; i <= m; ++i) {
		int b, w;
		cin >> a[i] >> b;
		for (int j = 0; j < b; ++j) {
			cin >> w;
			c[i] += (1 << (w - 1));
		}
	}
	int dp[m + 1][(1 << n)];
	for (int i = 0; i <= m; ++i) {
		for (int j = 0; j < (1 << n); ++j) 
			dp[i][j] = inf;
	}
	dp[0][0] = 0;
	for (int i = 1; i <= m; ++i) {
		for (int j = 0; j < (1 << n); ++j)
			dp[i][j] = dp[i - 1][j];
		for (int j = 0; j < (1 << n); ++j) 
			ckmin(dp[i][(j | c[i])], dp[i - 1][j] + a[i]);
	}
	if (dp[m][(1 << n) - 1] == inf)
		cout << -1 << '\n';
	else
		cout << dp[m][(1 << n) - 1] << '\n';
}


Measured memory_bytes: 16256
n=int(input())
h=list(map(int,input().split()))
dp=[float('inf')]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
  
  
#print(dp)
print(dp[n-1])

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

signed main(){
	fastio
	int ans = 0;
	string s;
	cin >> s;
	for(auto x : s){
		ans = (ans+(x-'0'));
	}
	cout << (ans%9==0 ? "Yes" : "No");
} 

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#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 FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    int s=0;
    str n;
    cin >> n;
    REP(i, n.size()) s = ( s + int(n[i]) - 48 ) % 9;
    Yes( s == 0 );
}


Measured memory_bytes: 3728
#include <iostream>
#include <algorithm>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N, M;
pll R[20000];


int main(void) {
  while(cin >> N >> M, N || M) {
    REP(i, 0, N) cin >> R[i].se >> R[i].fi;
    sort(R, R + N);
    reverse(R, R + N);
    ll ans = 0;
    REP(i, 0, N) {
      if(M > 0) {
        if(M >= R[i].se) {
          M -= R[i].se;
        } else {
          ans += R[i].fi * (R[i].se - M);
          M = 0;
        }
      } else {
        ans += R[i].fi * R[i].se;
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    ll dp[10][10]={};
    reps(i,1,N+1){
        ll x=i;
        while(x/10!=0) x/=10;
        ll ue=x,sita=i%10;
        ++dp[ue][sita];
    }
    ll ans=0;
    rep(ue,10){
        rep(sita,10){
            ans+=dp[ue][sita]*dp[sita][ue];
        }
    }
    cout<< ans <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

#define MOD 1000000007
#define N 100010

typedef double lf;
typedef long long ll;
#define int ll
typedef long double ld;
typedef unsigned long long ull;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef vector<pair<ll,ll > >vpll;
typedef vector<vll > vvll;
#define endl "\n"
#define sd(a) scanf("%d",&a)
#define sstr(a) scanf("%s",a)
#define sl(a) scanf("%lld",&a)
#define debug(a) printf("check%d\n",a)
#define clr(a) memset(a,0,sizeof(a))
#define rtn return 
#define gc getchar
#define pb push_back
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define lp(i,b) for(ll i = ll(0); i<ll(b) ; i++) 
#define lpit(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define mid(s,e) (s+(e-s)/2)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define fast ios_base::sync_with_stdio(NULL),cin.tie(0),cout.tie(0);
ll ip(){
  ll x = 0; bool isNeg = false; char c;
  c = gc();
  if(c == '-')  isNeg = true , c = gc();
  for( ; c >= '0'  && c <= '9' ; c = gc()); x = (x << 1) + (x << 3) + c - '0';
  if(isNeg) x *= -1;  return x;
}
//////////////////////////////////////////// CONTAINERS FOR FUNCTIONS MENTIONED IN TEMPLATE ///////////////////////////////////
#define MAX 100005
//bool isPrime[MAX];
//int spf[MAX];
//////////////////////////////////////////// FUNCTIONS THAT NEED COMMENTED OUT CONTAINERS ////////////////////////////////////


//void prime_sieve(){ for(ll i=2 ; i*i<=MAX ; i++){ if(!isPrime[i]){ for(ll j=i*i ; j<=MAX ; j+=i)  isPrime[j] = 1;} }  }
//void spf_sieve(){ for(ll i=2 ; i<MAX ; i+=2)  spf[i] = 2;
//  for(ll i=3 ; i<MAX ; i+=2){ if(!isPrime[i]){ spf[i] = i; for(ll j=i ; (j*i)<MAX ; j+=2){ if(!isPrime[i*j])  isPrime[i*j] = true , spf[i*j] = i; } } }
//}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline ll ncr(ll n,ll r){ ll ans = 1 ; if(r > n-r) r = n-r; lp(i,r+1){ans*=(n-i) ; ans/=(i+1); } rtn ans; }
inline ll gcd(ll a,ll b){if(!a) rtn b; rtn gcd(b%a,a); }
inline ll fme(ll x,ll n){ll ans=1;x%=MOD;while(n>0){if(n&1){ ans*=x;ans%=MOD;} x*=x;x%=MOD;n>>=1;}rtn ans%MOD;}
inline bool isPalin(string &s){ int len = s.size()-1;lp(i,(len/2)+2){if(!(s[i]==s[len-i]))  rtn false;} rtn true;}
inline ll lcm(ll a,ll b){rtn (a*b)/gcd(a,b); }
inline ll fmm(ll a,ll b) {ll r=0;a%=MOD;b%=MOD;while(b>0){if(b&1){r+=a;r%=MOD;}a+=a;a%=MOD;b>>=1;}rtn r%MOD;}
inline ll sfme(ll a,ll b) {ll r=1;a%=MOD;while(b>0){if(b&1)r=fmm(r,a);a=fmm(a,a);b>>=1;}rtn r%MOD;}
inline int in(){ int NR=0; register char c=gc(); while( c < 48 || c > 57 ){c=gc();} 
  while(c>47 && c< 58){ NR = (NR << 3) + (NR << 1) + (c - 48); c=gc();} return NR;
}

ll dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};
//--------------------------------TEMPLATE ENDS HERE--------------------------------------------------//

#define NMAX 100005
#define LOGNMAX 20




signed main(){
	fast;	
	
	string s;
	cin>>s;
	int ans=0;
	int i=0,j=s.length()-1;
	while(i<j){
		if(s[i]!=s[j]){
			ans++;
		}
		i++;
		j--;
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
using namespace std;

int main(){
	int N,k;
	cin>>N>>k;
	long long ans=0;
	REP(i,0,N-1) ans+=ans/(k-1)+1;
	p(ans);
}

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

int main(){
	int n; cin>>n; 
	for(int x=0;;x++){
		int y=n-4*x;
		if(y<0) break; 
		if(y%7==0){
			cout<<"Yes"; return 0; 
		}
	}
	cout<<"No"; 
}

Measured memory_bytes: 256
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define ra read_alpha()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline char read_alpha() { char c = ge; while(!isalpha(c) && c != EOF) c = ge; return c; }
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

#define ERROR return puts("No"), 0
#define OK return puts("Yes"), 0

const int MAXN = 100010;

vector<int>to[MAXN];
int vis[MAXN];
int A, B;

inline void dfs(int x) {
	vis[x] = 1;
	for(auto u : to[x])
		if(vis[u] == 2) A ? B = u : A = u;
		else if(!vis[u]) dfs(u);
}

int main() {
#ifdef LOCAL
	FILE("");
#endif
	int n = ri, m = ri, mxd = 0, mxc = 0;
	for(int i = 1; i <= m; i++) {
		int u = ri, v = ri;
		to[u].push_back(v);
		to[v].push_back(u);
	}
	for(int i = 1; i <= n; i++)
		if(to[i].size() & 1) ERROR;
		else if(to[i].size() > mxd) mxd = to[i].size(), mxc = 1;
		else mxc += mxd == to[i].size();
	if(mxd >= 6) OK;
	else if(mxd == 2 || mxc == 1) ERROR;
	else if(mxc > 2) OK;
	else {
		int cnt = 0;
		for(int i = 1; i <= n; i++)
			if(to[i].size() == 4)
				vis[i] = 2;
		for(int i = 1; i <= n; i++)
			if(!vis[i]) A = B = 0, dfs(i), cnt += A == B;
		puts(cnt ? "Yes" : "No");
	}
	return 0;
}

Measured memory_bytes: 6912
// AOJ Volume 0 Problem 0080

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

int main(void)
{
    int q;
	double x, j;

    while (1){
		scanf("%d", &q);
		if (q == -1){
			break;
		}
		
		x = q / 2;
		
		while (1){
			x = x - (x * x * x - q) / (3 * x * x);
			
//			printf("<%lf>\n", x);
			j = x * x * x - q;
			if (-0.00001 * q < j && j < 0.00001 * q){
				break;
			}
		}
		
		printf("%lf\n", x);
    }
    
    return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int n[1000];

int main()
{
	string n;
	cin >> n;
	int k = n.size();
	for (int i = 0; i < k; ++i)
	{
		cin >> n[i];
		if (n[i] == '1')
			n[i] = '9';
		else if (n[i] == '9')
			n[i] = '1';
	}
	cout << n;
}

Measured memory_bytes: 256
// clear time: 01:55
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>

using namespace std;
typedef pair<string, int> bug;
typedef map<string, int> closeMap;

int isOK(string str) {
    // cout << "str:" << str << " " << str.size() << endl;
    for ( int i = 0; i < str.size(); i++ ) {
        if ( str[0] != str[i] ) return 0;
    }
    return 1;
}

char cc(char a, char b) {
    // 並び替え
    if ( b < a ) {
        char tmp = a;
        a = b;
        b = tmp;
    }

    if ( a == 'b' && b == 'g' ) {
        return 'r';
    } else if ( a == 'b' && b == 'r' ) {
        return 'g';
    } else {
        return 'b';
    }
}

void wfs(string str) {
    int cnt = -1;
    string first = str;
    queue<bug> open;
    closeMap close;

    // 初期状態をプッシュ
    open.push( make_pair(str, 0) );

    close.insert( closeMap::value_type(str, 1) );
    // cout << str << " key:" << close[str] << endl;

    while(!open.empty()) {
        bug b = open.front(); open.pop();
        string cs = b.first;

        if ( isOK(cs) ) {
            cnt = b.second;
            break;
        }

        int c = 0;
        for ( int i = 1; i < cs.size(); i++ ) {
            if ( cs[i-1] != cs[i] ) {
                string tmp = cs;
                char nc = cc(cs[i-1], cs[i]);
                tmp[i-1] = nc;
                tmp[i] = nc;

                if ( close[tmp] )continue;
                open.push( make_pair(tmp, b.second+1) );
                close[tmp] = 1;
                c++;
            }
        }
    }

    if ( cnt == -1 ) {
        cout << "NA" << endl;
    } else {
        cout << cnt << endl;
    }


}

int main() {
    string n;

    while ( cin >> n, n != "0" ) {
        wfs(n);
    }

    return 0;
}

Measured memory_bytes: 2924
N, S = int(input()), str(input())
for i in range(N):
    if i == 0:
        res = S[1:].count('E')
        cost = res
    else:
        if S[i-1] == 'W': res += 1
        if S[i] == 'E': res -= 1
    cost = min(cost, res)
print(cost)

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

int main(int argc, char const *argv[]) {
  int N, K;
  cin >> N >> K;
  int h;
  int total = 0;
  for (int i = 0; i < N; i++) {
    cin >> h;
    if (h >= K) {
      total += 1;
    }
  }
  cout << total << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
using namespace std;
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
const int inf = 1e9+7;
int main() {
    string s; int q; cin >> s >> q;
    int n = s.length();
    auto dp = vectors(26+1, n, inf);
    repeat_reverse (i,n) {
        setmin(dp[s[i]-'a'][i], i+1);
        repeat (c,26) {
            if (dp[c][i] < n) {
                setmin(dp[c+1][i], dp[c][dp[c][i]]);
            }
        }
        repeat (c,26) {
            if (dp[26][i] < n) {
                setmin(dp[c][i], dp[c][dp[26][i]]);
            }
        }
    }
    int log_n = log2(n);
    auto skip = vectors(log_n+1, n, inf);
    skip[0] = dp[26];
    repeat (k,log_n) {
        repeat (i,n) {
            if (skip[k][i] < n) {
                skip[k+1][i] = skip[k][skip[k][i]];
            }
        }
    }
    while (q --) {
        int l, r; cin >> l >> r; -- l;
        int i = l;
        repeat_reverse (k, log_n+1) {
            while (i < n and skip[k][i] <= r) {
                i = skip[k][i];
            }
        }
        cout << (i == r ? "Yes" : "No") << endl;
    }
    return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int n; cin >> n;

    ll ans = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 1; j < n; j++) {
            if (i * j >= n) break;
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

pair<int,int> v[105];
ll dp[105][100005];
int n, w;
bool mark[105][100005];

ll f(int i, int j) {
	if(i == n) return j == 0 ? 0 : (ll)1e18;
	if(mark[i][j]) return dp[i][j];
	mark[i][j] = true;

	ll ret = f(i+1, j);
	if(j >= v[i].ss)
		ret = min(ret, f(i+1, j-v[i].ss) + v[i].ff);

	return dp[i][j] = ret;
}

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

	for(int i = 0; i < n; i++) 
		scanf("%d%d", &v[i].ff, &v[i].ss);

	for(int i = 100000; i >= 0; i--) {
		ll weight = f(0,i);
		if(weight <= w) {
			printf("%d\n", i);
			return 0;
		}
	}
	printf("0\n");
    
    return 0;
}

Measured memory_bytes: 90368
# ABC109D - Make Them Even
import sys
input = sys.stdin.readline

def main():
    H, W = tuple(map(int, input().split()))
    A = list(list(map(lambda x: int(x) % 2, input().split())) for _ in range(H))
    ans = []
    for i in range(H):  # move left to right
        for j in range(W - 1):
            if A[i][j]:
                A[i][j + 1] ^= 1
                ans += ["{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2)]

    for i in range(H - 1):  # move up to down
        if A[i][W - 1]:
            A[i + 1][W - 1] ^= 1
            ans += ["{} {} {} {}".format(i + 1, W, i + 2, W)]
    print(len(ans))
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

Measured memory_bytes: 18396
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
lli dp[3001][3001];
lli solve(int i, int j, int arr[]){
  if(dp[i][j]!=-1)
    return dp[i][j];
  if(i==j)
    return dp[i][j]=arr[i];
  return dp[i][j]=max(arr[i]-solve(i+1,j,arr),(arr[j]-solve(i,j-1,arr)));
}
int main(){
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  memset(dp,-1,sizeof(dp));
  cout<<solve(0,n-1,arr)<<"\n";
   return 0;
}

Measured memory_bytes: 74152
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
cnt = 0
score = {'r': p, 's': r, 'p': s}
for i in range(k):
  a, b = 0, score[t[i]]
  for j in range(i+k,n,k):
    a, b = b, b + score[t[j]] if t[j] != t[j-k] else a + score[t[j]]
  cnt += max(a, b)
print(cnt)

Measured memory_bytes: 42732
import sys

sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
P = list(map(int, input().split()))

sk = sum(P[:K])
n = sum(P[:K])
for i in range(N):
    if i < K:
        continue

    n -= P[i - K]
    n += P[i]

    sk = max(sk, n)
    prev = n

ans = sk / 2. + K / 2.
print(ans)


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

int main() 
{
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++)
        cin >> L[i];

    int max = *max_element(L.begin(), L.end());
    int sum = accumulate(L.begin(), L.end(), 0);
    
    if (sum - max > max)
    {
        cout << "Yes" << endl;
    } else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadLong;
			var primes = 1_000_000.EnumeratePrime();
			var indices = N.Decompose(primes);
			var res = 0;
			foreach(var i in indices) {
				var tri = 0;
				var j = 1;
				var k = 0;
				while(true) {
					tri+=j;
					if(i>=tri) {
						k++;
					} else {
						break;
					}
					j++;
				}
				res+=k;
			}
			Console.WriteLine(res);
		}

	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
		public static IEnumerable<long> Decompose(this long X, IEnumerable<int> primes) {
			foreach(var p in primes) {
				if(X<p) yield break;
				var index = 0;
				while(X%p==0) {
					X/=p;index++;
				}
				yield return index;
			}
			if(X!=1) yield return 1;
		}
		public static IEnumerable<int> EnumeratePrime(this int max) {
			yield return 2;
			var composed = new bool[(max-3)/2+1];  //3,5,7; 3,5; i->2*i+3
			for(int i = 0; i<composed.Length; i++) {
				if(composed[i]) continue;
				var j = 2*i+3;
				yield return j;
				for(int k = 3; k*j<=max; k+=2) {
					composed[(k*j-3)/2]=true;
				}
			}
		}
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
}

Measured memory_bytes: 28420
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct SqrtDecomposition {
	int n, sqrt_n, bucket_size;
	vector<int> data;
	vector<int> bucket;
	SqrtDecomposition(int n) :n(n), sqrt_n(sqrt(n)) {
		assert(n);
		bucket_size = 1 + (n - 1) / sqrt_n;
		data.assign(bucket_size * sqrt_n, 0);
		bucket.assign(bucket_size, 0);
	}
	int get(int x) {
		return data[x] + bucket[x / sqrt_n];
	}
	void add(int l, int r, int val) {
		for (int k = 0; k < bucket_size; k++) {
			int bl = k * sqrt_n, br = (k + 1) * sqrt_n;
			if (r <= bl || br <= l)
				continue;
			if (l <= bl && br <= r) {
				bucket[k] += val;
			}
			else {
				for (int i = max(l, bl); i < min(r, br); i++) {
					data[i] += val;
				}
			}
		}
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	SqrtDecomposition sd(n);
	rep(i, 0, q) {
		int com; cin >> com;
		if (com == 0) {
			int s, t, x; cin >> s >> t >> x;
			sd.add(s - 1, t, x);
		}
		else {
			int i; cin >> i;
			cout << sd.get(i - 1) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a>>b;
    int ans = 0;
    if(b%a==0)
        ans = a + b;
        else
        {
            ans = b-a;
        }
        
    cout <<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    static int N;
    static int min;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        N = sc.nextInt();
        sc.close();
        min = N;
        for(int i = 0; i <= N; i++){
            int by_6 = i;
            int by_9 = N-i;
            int count = 0;
            while(by_6 > 0){
                count += (by_6 % 6);
                by_6 /= 6;
            }
            while(by_9 > 0){
                count += (by_9 % 9);
                by_9 /= 9;
            }
            min = Math.min(count, min);
        }
        System.out.println(min);
    }

}

Measured memory_bytes: 22612
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin>>n;
    vector < pair<string, ll>> p;
    for (ll i = 0; i < n; i++)
    {
        string s;
        ll t;
        cin >> s >> t;
        p.push_back(make_pair(s, t));
    }
    string x;
    cin >> x;
    ll ans = 0;
    bool f = false;
    for (ll i = 0; i < n; i++)
    {
        if (f)
        {
            ans += p[i].second;
        }

        if (p[i].first == x)
            f = true;
    }
    cout << ans << endl;
}

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

int main()
{
    int N, max = 0;
    string S;
    cin >> N >> S;
    int sum = 0;
    rep(i, N)
    {
        if (S[i] == 'I')
        {
            sum++;
        }
        else
        {
            sum--;
        }
        if (max < sum)
        {
            max = sum;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n, s;
int f(int k, int sum, int max) {
	if (sum > s)return 0;
	if (k == n) {
		if (sum == s)return 1;
		else return 0;
	}
	if (max >= 9)return 0;
	int cnt = 0;
	for (int i = max + 1; i < 10; i++)
		cnt += f(k + 1, sum + i, i);
	return cnt;
}
int main() {
	while (cin >> n >> s, n) 
		cout << f(0, 0, -1) << endl;
}

Measured memory_bytes: 3120
A, B, C, K = map(int, input().split())

if K%2 == 0:
    if abs(A-B) <= 10**18:
        print(A-B)
    else:
        print("Unfair")
else:
    if abs(B-A) <= 10**18:
        print(B-A)
    else:
        print("Unfair")


Measured memory_bytes: 9044
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if(a%2==1&&b%2==1)cout << "Odd" << endl;
  else cout << "Even" << endl;
}


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

typedef long long ll;

void solve(int n) {
      cout << "Yes\n" << n << '\n';

      vector<int> ans[n+1]; int k = 1;
      for (int i = 1; i <= n; i++) {
            for (int j = i+1; j <= n; j++) {
                  ans[i].push_back(k);
                  ans[j].push_back(k);
                  k++;
            }
      }

      for (int i = 1; i <= n; i++) {
            cout << n-1 << ' ';
            for (int j: ans[i]) cout << j << ' ';
            cout << '\n';
      }
      exit(0);
}

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

      int n; cin >> n;
      for (int i = 1; i <= 1000; i++) {
            if (i*(i-1)/2 == n) {
                  solve(i);
            }
      }

      cout << "No";

      return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>

int main() {
	int a, b, c, temp;
	int n, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &a, &b, &c);
		if (a > c) {
			temp = c;
			c = a;
			a = temp;
		}
		if (b > c) {
			temp = c;
			c = b;
			b = temp;
		}
		if (a * a + b * b == c * c) {
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}

	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  char op;
  
  cin >> A >> op >> B;

  if(op == '+')
     cout << A + B << endl;
     else cout << A - B << endl;
  // ここにプログラムを追記
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	static int MAX_COUNT= 100000000;
	public static void main(String[] args){

		boolean[] isPrimeNumber = createIsPrimeNumber();
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 0;
		for(int i = 0; i <N; i++){
			int temp= sc.nextInt();
			if(isPrimeNumber[temp - 1]){
				count++;
			}
		}
		sc.close();
		System.out.println(count);
	}
	
	public static boolean[] createIsPrimeNumber(){
		boolean[] isPrimeNumber = new boolean[MAX_COUNT];
		for(int i = 0; i <MAX_COUNT; i++){
			isPrimeNumber[i] = true;
		}
		isPrimeNumber[0] = false;
		for(int i = 2; i < MAX_COUNT; i++){
			if(isPrimeNumber[i - 1]){
				int count = 2;
				while(true){
					if((i * count - 1) >= MAX_COUNT ){
						break;
					}
					isPrimeNumber[i * count - 1] = false;
					count++;
				}
			}
		}
		return isPrimeNumber;
	}
}

Measured memory_bytes: 129860
#include <stdio.h>

void merge(int*,int,int,int);
void mergeSort(int*,int,int);

int count=0;

int main(){
  int n,A[500000],i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  mergeSort(A,0,n);

  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);
  printf("%d\n",count);

  return 0;
}

void merge(int *A,int left,int mid,int right){
  int i,j,k,n1=mid-left,n2=right-mid;
  int L[n1],R[n2];

  for(i=0;i<n1;i++){L[i]=A[left+i];}
  for(j=0;j<n2;j++){R[j]=A[mid+j];}
  L[n1]=1000000001;
  R[n2]=1000000001;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }
    else{
      A[k]=R[j];
      j=j+1;
    }
  }
}

void mergeSort(int *A,int left,int right){
    int mid;
    if(left+1<right){
      mid = (left + right)/2;
      mergeSort(A,left,mid);
      mergeSort(A,mid,right);
      merge(A,left,mid,right);
    }
  }


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


int main() {
	ll n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		a[i]--;
	}
	//入力

	vector<int> check(n),root;
	int now = 0;
	int s,si; //ループの最初
	rep(i, n) {
		if (check[now] == 1) {
			s = now;
			break;
		}
		root.push_back(now);
		check[now] = 1;
		now = a[now];
	}
	rep(i, root.size()) {
		if (root[i] == s) {
			si = i;
			break;
		}
	}
	if (k <= si) {
		cout << root[k] + 1 << endl;
		return 0;
	}
	int rn = root.size() - si;
	int ansi = (k - si) % rn;
	cout << root[ansi+si] + 1 << endl;
}



Measured memory_bytes: 5888
import java.util.*;

class Chara {
    String name;
    ArrayList<Integer> appear;
    private int point;

    Chara(String name, ArrayList<Integer> appear) {
        this.name = name;
        this.appear = appear;
        this.point = 0;
    }

    void addPoint(int pt) {
        this.point += pt;
    }

    int getPoint() {
        return this.point;
    }
}

class Main {

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);
        while(true) {
            int n = Integer.parseInt(sc.nextLine());
            if( n == 0 )    break;
            
            Chara [] charas = new Chara[n];
            for(int i = 0; i < n; i++) {
                String [] line = sc.nextLine().split(" ");
                ArrayList<Integer> appear = new ArrayList<Integer>();
                for(int j = 2; j < line.length; j++) {
                    appear.add(Integer.parseInt(line[j]));
                }
                charas[i] = new Chara(line[0], appear);
            }

            for(int t = 0; t < 30; t++) {
                int point = n + 1;
                for (Chara c : charas) {
                    if (c.appear.indexOf(t) != -1) {
                        point -= 1;
                    }
                }
                for (Chara c : charas) {
                    if (c.appear.indexOf(t) != -1) {
                        c.addPoint(point);
                    }
                }
            }

            ArrayList<Integer> points = new ArrayList<Integer>();
            for(Chara c : charas) {
                points.add(c.getPoint());
            }
            int min = Collections.min(points);

            ArrayList<String> minNames = new ArrayList<String>();
            for(Chara c : charas) {
                if (c.getPoint() == min) {
                    minNames.add(c.name);
                }
            }
            Collections.sort(minNames);

            System.out.printf("%d %s\n", min, minNames.get(0));
        }

    }
}

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

abc = [list(map(lambda x: int(x), input().split())) for _ in range(N)]

happy = [[0] * 3 for _ in range(N)]
for i in range(3):
	happy[0][i] = abc[0][i]

for i in range(1, N):
	for j in range(3):
		for k in range(3):
			if j != k and happy[i][j] < happy[i - 1][k]:
				happy[i][j] = happy[i - 1][k]
		happy[i][j] += abc[i][j]

print(max(happy[N - 1][0], happy[N - 1][1], happy[N - 1][2]))

Measured memory_bytes: 47280
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	_ = iScan()
	s := Scan()
	x, y := 0, 0
	for _, r := range s {
		if string(r) == "I" {
			x += 1
			y = larger(y, x)
		} else {
			x -= 1
		}
	}
	fmt.Println(y)
}


Measured memory_bytes: 1772
def main
  n, k = gets.chomp.split.map(&:to_i)
  h = gets.chomp.split.map(&:to_i).sort.reverse
  sum = 0
  return 0 if k >= h.length
  #k + 1番目以降を合計
  h.each_with_index do |v, idx|
    next if idx < k
    sum += v
  end
  
  return sum
end

puts main

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

using namespace std;

int main() {
	int x;
	cin >> x;
	int basket[1001] = {};
	basket[1] = 1;
	for (int i = 2; i <= x; i++)
	{
		int tmp = i;
		while (true)
		{
			tmp = tmp * i;
			if (tmp > 1000) break;
			else basket[tmp]++;
		}
	}
	int ans = 1;
	for (int i = 1; i <= x; i++)
	{
		if (basket[i] > 0) ans = max(ans, i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
n,m=map(int,input().split())
A=[int(i) for i in input().split()]
B=[0]
for i in range(n):
    B.append((B[-1]+A[i])%m)
B.sort()
cnt=1
now=0
ans=0
for i in range(1,n+1):
    if B[i]>now:
        ans+=cnt*(cnt-1)//2
        cnt=1
        now=B[i]
    else:
        cnt+=1
ans+=cnt*(cnt-1)//2
print(ans)



Measured memory_bytes: 20436
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 1e2 + 5;
int a[maxn];
int n, cnt;
int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(int i = 0; i < n - 1; i++){
		int tail = n - 1;
		for(int j = tail - 1; j >= 0; j--){
			if(a[j] > a[tail]){
				swap(a[j], a[tail]);
				tail--;
				cnt++;
			}else{
				tail--;
			} 
		}
	}
	int first = 1;
	for(int i = 0; i < n; i++){
		if(first)first = 0;
		else printf(" ");
		printf("%d", a[i]);
	} 
	printf("\n");
	printf("%d\n", cnt);
	return 0;
}


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

public class Main {
  private static boolean solve(char[][] cm) {
    return cm[0][0] == cm[1][2] && cm[0][1] == cm[1][1] && cm[0][2] == cm[1][0];
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    char[][] cm = reader.nextCharArray(2);
    out.println(solve(cm) ? "YES" : "NO");
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21204
#include <stdio.h>
#include <algorithm>

int field[10][2][10000];
int h,w;
int row_sum;
int col_sum;
int sum = 0;
int now_sum = 0;
int ans[5];
int n = 0;
int sel[10];


void all(int k){
  if(k != h){
    sel[k] = 0;
    all(k+1);
    sel[k] = 1;
    all(k+1);
  }
  now_sum = 0;
  for(int j = 0; j < w; j++){
    col_sum = 0;
    for(int i = 0; i < h; i++){
      col_sum += field[i][sel[i]][j];
    }
    now_sum += std::max(col_sum,h-col_sum);
  }
  sum = std::max(now_sum,sum);
}

int solve(){
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      field[i][1][j] = (field[i][0][j] + 1) % 2;
    }
  }
  all(0);
  return sum;
}

int main(){
  while(true){
    scanf("%d %d",&h, &w);
    if(h == 0 && w == 0)
      break;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        scanf("%d", &field[i][0][j]);
      }
    }
    ans[n++] = solve();
  }
  for(int i = 0; i < n; i++){
    printf("%d\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 3356