akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define INF (ll)1000000007
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){

    ll x;
    cin >> x;

    ll ans = x/11;
    if(x - 11*ans > 6) ans = 2*(ans+1);
    else ans = 2*ans + 1;
    if(x%11 == 0) ans--;
    cout << ans << endl;

    return 0;
}

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

#include <algorithm>

using namespace std;

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


vector<double> vec(N);
  
for(int i=0;i<N;i++){
	cin>>vec.at(i);  

}
  sort(vec.begin(),vec.end());
//reverse(vec.begin(),vec.end());
  double t=0.0;
for(int i=0;i<N-1;i++){
  t=vec.at(i)+vec.at(i+1);
  t=t/2;
  vec.at(i+1)=t;
  
	  

}
  cout<<vec.at(N-1)<<endl;
  
  

  

  
  
  
  
  
  
  
  
  
  
  
  
}


Measured memory_bytes: 256
right = {"y", "u", "i", "o", "p", "h", "j", "k", "l", "n", "m"}
while 1:
	key_input = raw_input()
	if key_input == "#":
		break
	hand = "N"
	count = 0
	for c in key_input:
		if c in right :
			if hand == "L":
				count += 1
			hand = "R"
		else :
			if hand == "R":
				count += 1
			hand = "L"
	print count

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5;
int n, cnt1 = 1, cnt2 = 1;
ll ans;
bool used[Maxn];
struct str
{
	int a, b, id;
} A[Maxn], B[Maxn];
bool cmp1(str x, str y) { return x.a + x.b > y.a + y.b || (x.a + x.b == y.a + y.b && x.a > y.a); }
bool cmp2(str x, str y) { return x.a + x.b > y.a + y.b || (x.a + x.b == y.a + y.b && x.b > y.b); }
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d%d", &A[i].a, &A[i].b);
		A[i].id = i;
		B[i] = A[i];
	}
	sort(A + 1, A + n + 1, cmp1);
	sort(B + 1, B + n + 1, cmp2);
	for (int i = 1; i <= n; i++)
	{
		if (i & 1)
		{
			while (cnt1 < n && used[A[cnt1].id])
				cnt1++;
			ans += A[cnt1].a;
			used[A[cnt1++].id] = true;
		}
		else
		{
			while (cnt2 < n && used[B[cnt2].id])
				cnt2++;
			ans -= B[cnt2].b;
			used[B[cnt2++].id] = true;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

bool check(vector<P> vec){
    int h = 0;
    for(auto p : vec){
        int b = h + p.first;
        if(b < 0) return false;
        h += p.second;
    }
    return true;
}

int main(){
    int n; cin >> n;
    vector<P> ls, rs;
    int total = 0;
    rep(i,n){
        string s; cin >> s;
        int h = 0, b = 0;//h:増減,b:最下点
        for(auto c : s){
            if(c == '(') h++;
            else h--;
            b = min(b,h);
        }
        if(h > 0)ls.emplace_back(b, h);
        else rs.emplace_back(b-h, -h);
        total += h;
    }
    sort(RALL(ls));
    sort(RALL(rs));
    if(check(ls) && check(rs) && total == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 18996
#include <iostream>
#include <string>
using namespace std;
int main(){
	string find,tmp;
	cin >> find;
	int count = 0,num;
	cin >> num;
	for (int i = 0; i < num; i++){
		cin >> tmp;
		tmp += tmp;
		int loc = tmp.find(find, 0);
		if (loc != string::npos)
			count++;
	}
	cout << count << endl;


}

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

int main(){
    string s;
    cin>>s;
    bool a = false, b = false, c = false;
    for(int i=0; i<s.size(); i++) {
        if(s[i] == 'a') a = true;
        if(s[i] == 'b') b = true;
        if(s[i] == 'c') c = true;
    }
    if(a && b && c) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		long num = stdin.nextLong() + 1;
		String numStr = String.valueOf(num);
		int len9 = numStr.length() - 1;
		int top = Integer.parseInt(numStr.substring(0, 1)) - 1;

		int max = top + 9 * len9;
		System.out.println(max);
	}

}


Measured memory_bytes: 21844
/*
g++ -std=c++14 -o2 -Wall exawizards2019A.cpp -o .\out\exawizards2019A.out
.\out\exawizards2019A.out
*/

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

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;

namespace ITP1_3_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var sb = new StringBuilder();

            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                if (input.All(n => n == "0"))
                    break;
                var a = int.Parse(input[0]);
                var b = int.Parse(input[1]);
                sb.AppendLine(string.Format("{0} {1}", Math.Min(a, b), Math.Max(a, b)));
            }
            Console.Write(sb);
        }
    }
}

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

char ary[110];
bool cnt[26];
int main(){
	cin>>ary;
	int N=strlen(ary);
	int a;
	for(int i=0;i<N;i++){
		a=ary[i]-'a';
		cnt[a]=!cnt[a];
	}
	bool res=true;
	for(int i=0;i<26;i++){
		if(cnt[i]){
			res=false;
			break;
		}
	}
	if(res){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<functional>
using  namespace std;
typedef long long ll;
#define sc(x) scanf("%d",&x)
#define pd(x) printf("%d\n",x)
const int INF=1e9+10;
const int MOD=1e9+7;
const double eps=1e-5;
const double pi=acos(-1.0);
const int N=2e5+5;
int a[N];
int main()
{
    int n,p;
    while(~scanf("%d%d",&n,&p))
    {
        int x,ji=0,ou=0;
      for(int i=0;i<n;i++)
      {
          scanf("%d",&x);
          if(x&1) ji++;
          else ou++;
      }
      if(ji==0)
      {
         if(p) puts("0");
         else printf("%lld\n",ll(1)<<n);
      }
      else printf("%lld\n",ll(1)<<(n-1));
    }
    return 0;
}


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

int main(){

  int64_t N;
  cin>>N;

  string al="abcdefghijklmnopqrstuvwxyz";

  string t;
  while(N>0){
    --N;
    int q=N%26;
    t=al[q]+t;
    N=(N-q)/26;
    
  }

  cout<<t<<endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include <math.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;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int N;
  cin >>N;
  vector<int> vec(N);
  rep(i,N) {
cin >>vec.at(i);
  }
  
  sort(all(vec));
  cout<<vec.at(N-1)-vec.at(0)<< endl;
}
  
 

Measured memory_bytes: 256
n = input()
s = list(map(int,input().split()))

MAX = max(s)
nums = [0]*(MAX+1)

if MAX == 0:
    print(n)
    exit()

for i in s:
    if i == 0:
        nums[0] += 1
        nums[1] += 1
    elif i == MAX:
        nums[-1] += 1
        nums[-2] += 1
    else:
        nums[i-1] += 1
        nums[i] += 1
        nums[i+1] += 1

print(max(nums))

Measured memory_bytes: 13964
S=list(input())

N=len(S)
i=0


while(True):
  #print(N,i)
  if((S[i]==S[N-i-1]) and (S[i]==S[int(N/2)-i-1])):
    i=i+1
  else:
    print("No")
    break
  if(i==(int((N-1)/2))):
    print("Yes")
    break
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector< ll > vi;
typedef vector< vi > vvi;
#define pb push_back

int main(void)
{
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.length()-1]==b[0]&&b[b.length()-1]==c[0])
    	cout << "YES" << endl;
   	else
   		cout << "NO" << endl;
   	return 0;
}

Measured memory_bytes: 256
import Control.Applicative

data Dice = Dice { top    :: Int
                 , bottom :: Int
                 , front  :: Int
                 , back   :: Int
                 , left   :: Int
                 , right  :: Int
                 } deriving (Show)

toN :: Dice -> Dice
toN dice = Dice { top    = front  dice
                , bottom = back   dice
                , front  = bottom dice
                , back   = top    dice
                , left   = left   dice
                , right  = right  dice
                }

toS :: Dice -> Dice
toS dice = Dice { top    = back   dice
                , bottom = front  dice
                , front  = top    dice
                , back   = bottom dice
                , left   = left   dice
                , right  = right  dice
                }

toE :: Dice -> Dice
toE dice = Dice { top    = left   dice
                , bottom = right  dice
                , front  = front  dice
                , back   = back   dice
                , left   = bottom dice
                , right  = top    dice
                }

toW :: Dice -> Dice
toW dice = Dice { top    = right  dice
                , bottom = left   dice
                , front  = front  dice
                , back   = back   dice
                , left   = top    dice
                , right  = bottom dice
                }

main = do
    [a, b, c, d, e, f] <- map read . words <$> getLine
    let dice = Dice { top = a, front = b, right = c, left = d, back = e, bottom = f}
    mvstr <- getLine
    print $ move dice mvstr

move :: Dice -> String -> Int
move dice [] = top dice
move dice (x:xs) =
    case x of
      'S' -> move (toS dice) xs
      'N' -> move (toN dice) xs
      'E' -> move (toE dice) xs
      _   -> move (toW dice) xs


Measured memory_bytes: 3552
#include<iostream> 
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++) 

int main() {
    string N;
    cin >> N;
    
    if (N[0] == N[1] && N[1] == N[2]) {
        cout << "Yes" << endl;
    } else if (N[1] == N[2] && N[2] == N[3]) {
        cout << "Yes" << endl;
    } else if (N[0] == N[1] && N[1] == N[2] && N[2] == N[3]) {
        cout << "Yes" << endl;
    } else cout << "No" << endl;
}

Measured memory_bytes: 256
l = list(input().split())
l[0] = int(l[0])
l[1] = int(l[1])
l[2] = int(l[2])
l[0], l[1]=l[1], l[0]
l[0], l[2]=l[2], l[0]
print(l[0], l[1], l[2])

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	int n,sum,i,b,a[200000];
	cin>>n;
	sum=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&b);
		sum+=b;
	}
	cout<<sum-n<<endl;
	return 0;
 } 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = ReadString();
            Out(S[0] + S[1] + S[2] - 3 * '0');
        }

        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static void Out(object o)
        {
            Console.WriteLine(o);
        }
    }

    static class EnumerableExtension
    {
        public delegate void Function<in T>(T val);

        public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function)
        {
            foreach (var x in enumerable)
            {
                function(x);
            }
        }
    }
}

Measured memory_bytes: 11092
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1)*18;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int n,a;cin>>n>>a;
	cout<<(a>=n%500?"Yes":"No")<<endl;RE;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define P push
#define PQ priority_queue<double, vector<double>, greater<double> >q
#define _sort(v) sort(v.begin(),v.end())
#define MP map<ll int,ll int>mp
#define MEM(x) memset(x,0,sizeof(x))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define VEC() vector<ll int>v
#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
//Upper_bound   auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; if(x==v[a].end())break;
//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//ll mod_inverse(ll a, ll mod){return bigmod(a,mod-2,mod);}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;strRescan ing mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}
//string add(string s,int n){ string res; int c=n,x; for(int i=s.size()-1;i>=0;i--)   { x=s[i]-'0'+c;res+=(x%10+'0'); c=x/10; }    while(c)    { res+=(c%10+'0'); c=c/10;} reverse(res.begin(),res.end()); return res;}

int main()
{
    FAST();
  ll int n,m,res=0,cnt=0,x;
  cin>>n>>m>>x;
  cout<<(n+m-1)/m*x<<endl;





    return 0;
}



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

using namespace std;
int a[10];

int main()
{
    for(int i = 0;i<5;i++) cin >> a[i];
    int k;
    cin >> k;
    sort(a , a + 5);
    if(a[4] - a[0] > k)  cout <<":(";
    else  cout << "Yay!";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if (a==b){
        cout << c << endl;
    }else if(b==c){
        cout << a << endl;
    }else{
        cout << b << endl;

    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int A, B;
	int P, Q, R;
	int kyori;
	if (scanf("%d%d", &A, &B) != 2) return 1;
	if (scanf("%d%d%d", &P, &Q, &R) != 3) return 1;
	kyori = P * B - Q * (B - A);
	printf("%.15f\n", B + (double)kyori / (Q + R));
	return 0;
}



Measured memory_bytes: 2128
#include<stdio.h>
int ta[100010],to[400040],co[400040],nt[400040];
long long d[100010];
int main(){
  int n,m,i,j,t,r,a,b,c,q[100010],u[100010]={};
  for(i=0;i<100005;i++)d[i]=ta[i]=-1;
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d %d %d",&a,&b,&c);
    nt[i  ]=ta[to[i+m]=a];
    nt[i+m]=ta[to[i  ]=b];
    co[ta[b]=i+m]=-c;
    co[ta[a]=i  ]= c;
  }
  for(j=1;j<=n;j++){
    if(u[j])continue;
    d[j]=1e10;
    q[t=0]=j;
    u[q[t]]=1;
    for(r=1;r-t;t++){
      //for(i=0;i<n;i++)printf("%d ",d[i+1]);printf("\n");
      for(i=ta[q[t]];i+1;i=nt[i]){//printf("%d %d\n",q[t],to[i]);
		if(d[to[i]]>0&&d[to[i]]!=d[q[t]]+co[i])goto END;
		if(u[to[i]])continue;
		d[to[i]]=d[q[t]]+co[i];
      	u[to[i]]=1;
		q[r++]=to[i];
      }
    }
  }
  printf("Yes\n");
  return 0;
 END:;
  printf("No\n");
  return 0;
}


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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int f(int N){
    int res = 0;
    while (N % 2 == 0) {
        N /= 2;
        res++;
    }
    return res;
}

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

    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
        A[i] /= 2;
    }

    rep(i, N - 1) {
        if (f(A[i]) != f(A[i + 1])) {
            puts("0");
            return 0;
        }
    }

    ll lcm = 1;
    rep(i, N) lcm = lcm * A[i] / __gcd(lcm, (ll)A[i]);

    cout << M / lcm - M / (lcm * 2) << endl;
}

Measured memory_bytes: 640
using System;

class EntryPoint
{
    static void Main()
    {
        int S = int.Parse(Console.ReadLine());
        Time t = new Time();
        t.Watch(S);
    }
}

class Time
{
    public void Watch(int S)
    {
        int h = S / 3600;
        int m = (S - (h * 3600)) / 60;
        int s = S - (h * 3600) - (m * 60);
        Console.WriteLine("{0}:{1}:{2}", h, m, s);
    }
}

Measured memory_bytes: 9072
def main():
  n,k=map(int,input().split())
  p=list(map(int,input().split()))
  t=input()
  s='rsp'
  dp=[[-10**10]*(n+k) for _ in range(3)]
  for i in range(k):
    for j in range(3):
      dp[j][i]=0
  for i in range(n):
    for j in range(3):
      for l in range(3):
        if j==l:
          continue
        res=((s.index(t[i])-l+3)%3==1)*p[l]
        if dp[l][i+k]<dp[j][i]+res:
          dp[l][i+k]=dp[j][i]+res
  ans=0
  for i in range(n,n+k):
    ans+=max(dp[0][i],dp[1][i],dp[2][i])
  print(ans)
main()

Measured memory_bytes: 20980
from collections import deque
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(M):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    G[l].append([r, d])
    G[r].append([l, -d])
INF = float('inf')
dist = [INF]*N
seen = [False]*N
q = deque([])
for s in range(N):
    if dist[s] != INF:
        continue
    q.append([s,0])
    while len(q) != 0:
        p = q.popleft()
        if seen[p[0]] and dist[p[0]] != p[1]:
            print('No')
            exit()
        elif seen[p[0]] and dist[p[0]] == p[1]:
            continue
        else:
            dist[p[0]] = p[1]
            seen[p[0]] = True
            for np in G[p[0]]:
                q.append([np[0], p[1] + np[1]])
print('Yes')

Measured memory_bytes: 108892
import java.util.Scanner;

//Third Root
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			double q = sc.nextDouble();
			if(q==-1)break;
			double x = Math.abs(q/2);
			while(Math.abs(x*x*x-q)>=0.000001*q)x = x-(x*x*x-q)/(3*x*x);
			System.out.printf("%.6f\n", x);
		}
	}
}

Measured memory_bytes: 12000
n, y = map(int, input().split())
b = [-1, -1, -1]
count = 0
for i in range(n + 1):
  for j in range(n + 1):
    k = n - i - j
    if k < 0:
      break
    total = 10000 * i + 5000 * j + 1000 * k
    count += 1
    if total == y and (i + j + k) == n:
      b = [i, j, k]
print('{0} {1} {2}'.format(b[0], b[1], b[2]))

Measured memory_bytes: 3064
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    if len(s) == 2:
        print(s)
    if len(s) == 3:
        print(s[::-1])
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39024
#include <iostream>
#include <stdio.h>

using namespace std;

void solve()
{
	int l[10] ,v1 ,v2;
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2], &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2) != EOF)
	{
		double posA = 0.0;
		double posB = 0.0;
		for(int i = 0; i < 10; ++i)
		{
			posB += l[i] * 1000;
		}
		int speedA = v1;
		int speedB = v2;
		while(posA < posB)
		{
			posA += speedA;
			posB -= speedB;
		}
		int dist = 0;
		for(int i = 0; i < 10; ++i)
		{
			dist += l[i] * 1000;
			if(posA <= dist)
			{
				cout << i + 1 << endl;
				break;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define int long long
map<int,int> Map;
int n,x,ans,sum;
signed main(){
	scanf("%lld",&n);
	Map[0]++;
	for (int i=1;i<=n;i++){
		scanf("%lld",&x);
		sum+=x;
		ans+=Map[sum];
		Map[sum]++;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 12800
#include <iostream>
#include <queue>

using namespace std;

int main(){
  int K;
  cin >> K;
  queue<long long> q;

  for (int i = 1; i < 10; i++){
    q.push(i);
  }

  long long x;
  for (int i = 0; i < K; i++){
    x = q.front();
    q.pop();
    if(x%10 != 0){
      q.push(10*x + x%10 - 1);
    }
    q.push(10*x + x%10);

    if(x%10 != 9){
      q.push(10*x + x%10 + 1);
    }
  }
  
  printf("%lld\n", x);
  
}


Measured memory_bytes: 5228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    string s; cin >> s;
    map<char, int> mp;

    for(int i=0; i<s.size(); i++) mp[s[i]]++;

    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        if(itr->second != 2){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

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

int main() 
{
	int a, b, c;
    cin>>a>>b>>c;
    if((a == b && a != c) || (a == c && b != c) || (b == c && b != a)) cout<<"Yes";
    else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
 int main() {
    string a,b;
    cin>>a;
    cin>>b;
    int al=a.length();
    int bl=b.length();
    if(al>bl){
        cout<<"GREATER"<<endl;
        return 0;
    }else if(al<bl){
        cout<<"LESS"<<endl;
        return 0;
    }
    for(int i=0;i<al;i++){
        if(a[i]>b[i]){
            cout<<"GREATER"<<endl;
            return 0;
        }else if(a[i]<b[i]){
            cout<<"LESS"<<endl;
            return 0;
        }
    }
    cout<<"EQUAL"<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
struct Union_Find {
    //各要素が属する集合の代表(根)を管理する
    //もし、要素xが根であればdata[x]は負の値を取り、-data[x]はxが属する集合の大きさに等しい
    vector<int> data;
 
    Union_Find(int size) : data(size, -1) {}
    bool Union(int x, int y) {
        x = Find(x);
        y = Find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return is_union;
    }
    int Find(int x) {
        if (data[x] < 0) { //要素xが根である
            return x;
        } else {
            data[x] = Find(data[x]); //data[x]がxの属する集合の根でない場合、根になるよう更新される
            return data[x];
        }
    }
    bool same(int x, int y) {
        return Find(x) == Find(y);
    }
    int size(int x) {
        return -data[Find(x)];
    }
};
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }

    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    } 
 
    Union_Find uf(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        uf.Union(x, y);
    }
 
    vector<int> used(n, false);
    vector<int> idxs(n);
    for (int i = 0; i < n; i++) idxs[i] = i;
    int hoge = 0;
    for (int i = 0; i < n; i++) {
        hoge += (i == uf.Find(i));
    }
    if (hoge == 1) {
        cout << 0 << endl;
        return 0;
    }
    sort(idxs.begin(), idxs.end(), [&](const int& i1, const int& i2){return a[i1] < a[i2];});
    ll ans = 0;
    int cnt = hoge - 2;
    int total = 2 * (hoge - 1);
    for (int i : idxs) {
        if (used[uf.Find(i)]) {
            if (cnt > 0) {
                cnt--;
                ans += a[i];
                total--;
            }
        } else {
            used[uf.Find(i)] = true;
            ans += a[i];
            total--;
        }
    }
    if (total == 0) cout << ans << endl;
    else cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 2176
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

double l[25], a[25], b[25];
signed main(void)
{
	int n, m;
	cin >> n >> m;
	REP(i, n) cin >> l[i] >> a[i] >> b[i];

	double ans = -1;
	REP(i, 1<<n) {
		int cnt = 0;
		VI c;
		REP(j, n) {
			if(i>>j&1) {
				cnt++;
				c.PB(j);
			}
		}
		if(cnt != m) continue;
		double ret = 0;
		REP(j, m) FOR(k, j+1, m) {
			ret += (l[c[j]]-l[c[k]])*(l[c[j]]-l[c[k]]) + (a[c[j]]-a[c[k]])*(a[c[j]]-a[c[k]]) + (b[c[j]]-b[c[k]])*(b[c[j]]-b[c[k]]);
		}
		if(ret > ans) ans = ret;
	}
	cout << fixed << setprecision(9) << ans << endl;

	return 0;
}

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

int main(void){
  int n;
  cin >> n;
int a[n];
for(int i=0;i<n;i++){
cin >>a[i];
}
double total=0;
double heikin=0;
for(int i=0;i<n;i++){
total = total+a[i];
}
heikin = total / n;
double sa[n];
for(int i=0;i<n;i++){
sa[i] = a[i]-heikin;
if(sa[i]<0){
sa[i] = -sa[i];
}
}

int out=0;
double check = 9999;

for(int i=0;i<n;i++){
if(sa[i]<check){
check = sa[i];
out = i;

}

}

cout << out << endl;

  return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
//#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#define  si(a)       scanf("%d",&a)
#define  sl(a)       scanf("%lld",&a)
#define  sii(a,b)    scanf("%d%d",&a,&b)
#define  sll(a,b)    scanf("%lld%lld",&a,&b)
#define  queues      priority_queue
#define mod 1000000007
#define mem(a)  memset(a,0,sizeof(a));
#define def(a) ((a)&(-a))
#define fi  first
#define se  second
#define mp  make_pair
#define  pb push_back
typedef long long ll;
//priority_queue<int,vector<int >,greater<int > >q;
const ll INF=0x3f3f3f3f;
const double E=exp(1);
const double PI=acos(-1);
using namespace std;
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c*=a;
        a*=a;
        b>>=1;
    }return c;
}
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
bool cmp(int a,int b)
{
    return a>b;
}
int ans[100003];
int ans1[100003];
int sum;
int sum1;
int main()
{
   int n,m;
   cin>>n>>m;
   string s;
   cin>>s;
   int z=0;
  if(s[0]=='0')ans1[++sum1]++;
  else ans[++sum]++;
   for(int i=1;i<n;i++)
    { int a=s[i]-'0';
        if(a==0)
        {    if(s[i]==s[i-1])
            ans1[sum1]++;
            else ans1[++sum1]++;
        }
        else {
            if(s[i]==s[i-1])ans[sum]++;
            else ans[++sum]++;
        }
    }//cout<<sum<<endl;
    for(int i=1;i<=sum+m;i++)
        ans[i]+=ans[i-1];
    for(int i=1;i<=sum1+m;i++)
        ans1[i]+=ans1[i-1];
        for(int i=1;i<=sum;i++)
        {
           // cout<<ans[i]<<endl;
        }
    int Max=0;
    for(int i=1;i<=sum1;i++)
    {
        int S=0;
        if(s[0]=='1')  S+=ans[i+m]-ans[i-1];
      else S+=ans[i+m-1]-ans[i-2];

        S+=ans1[i+m-1]-ans1[i-1];

        Max=max(Max,S);
    }
    if(Max==0)Max=ans[sum];
    cout<<Max<<endl;
}
/******************************************
**        **             ********       **
**       ** **           **             **
**      **   **          **             **
**     **     **         **             **
**    ***********        **             **
**   **         **       ********       **
******************************************/


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int cost[14],ara[13][13],pos[14],cnt[14],ans,n,m,x;
bool flag[14];
int c;

void cal(int now, int k, int take)
{
    int i;
    if(take==k)
    {
        c++;
        int cst=0;
        for(i=1; i<=n; i++)cnt[i]=x;
        for(i=1; i<=k; i++)
        {
            cst+=cost[pos[i]];
            for(int j=1; j<=m; j++)cnt[j]-=ara[pos[i]][j];
        }
        for(i=1; i<=m; i++)
            if(cnt[i]>0)break;
        if(i>m)ans=min(ans,cst);
        return;
    }
    if(now==n)return;
    for(i=now+1; i<=n; i++)
    {
        if(!flag[i])
        {
            flag[i]=true;
            pos[take+1]=i;
            cal(i,k,take+1);
            flag[i]=false;
        }
    }
}

int main()
{
    int i,j;
    scanf("%d %d %d",&n,&m,&x);
    for(i=1; i<=n; i++)
    {
        scanf("%d",&cost[i]);
        for(j=1; j<=m; j++)scanf("%d",&ara[i][j]);
    }
    ans=1e9;
    for(i=1; i<=n; i++)cal(0,i,0);
    if(ans==1e9)printf("-1\n");
    else printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3776
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		char[] strz = sc.next().toCharArray();
		
		int min = 100;
		
		for(int i=0; i<26; i++) {
			char key = (char) ('a' + i);
			int cnt = 0;
			
			char[] str = new char[strz.length];
			
			for(int j=0; j<strz.length; j++) {
				str[j] = strz[j];
			}
			
			while(true) {
				
				boolean flag = false;

				for(int j=0; j<str.length; j++) {
					if(str[j] != key) {
						flag = true;
						break;
					}
				}
				
				if(!flag) {
//					System.out.println((char)key + " " + cnt);
					if(cnt < min) {
						min = cnt;
					}
					break;
				}
				
				char[] next = new char[str.length - 1];
			
				for(int j=0; j<next.length; j++) {
					if(str[j] == key || str[j+1] == key) {
						next[j] = key;
					} else {
						next[j] = (char) (key - 1);
					}
				}
				
				cnt++;
				
				if(next.length == 1) {
					break;
				}
				

//				System.out.println(next);
				
				str = next;
			}
		}
		
		System.out.println(min);
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}



Measured memory_bytes: 23124
#include <iostream>

using namespace std;
int a, b, c, d;

int main(){
  cin >> a >> b >> c >> d;
  int k = 0;
  while (a>0 && c>0){
    if (k) a -= d;
    else c-=b;
    k^=1;
  }
  if (k) cout << "Yes";
  else cout << "No";
}



Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	int N, M;
	int INF = Integer.MAX_VALUE / 2;
	int[][] graph;
	Map<Integer, Map<Integer, Integer>> dp = new HashMap<>();

	void run() {
		N = sc.nextInt(); 
		M = sc.nextInt();
		graph = new int[N][N];
		
		for (int i = 0; i < N; i++) {
			Arrays.fill(graph[i], INF);
		}
		for (int i = 0; i < M; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			int cost = sc.nextInt();
			graph[s][t] = cost;
		}
		
	    int res =  tsp(1, 0);
	    System.out.println(res == INF ? -1 : res);
	}
	
	

	int tsp(int mask, int v) {
		if (dp.containsKey(mask) && dp.get(mask).containsKey(v))  return dp.get(mask).get(v);
		
		if (mask == (1 << N) - 1) return graph[v][0];

		int res = INF;
		for (int i = 0; i < N; i++) {
		    if((mask & (1 << i)) != 0) continue;
		    int tmp = graph[v][i] + tsp(mask | (1 << i), i);
		    if(tmp < res) res = tmp;
		}
		
		if(!dp.containsKey(mask)){
		   dp.put(mask, new HashMap<>());
		}
		
		dp.get(mask).put(v,res);
		
		return res;
	}

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


Measured memory_bytes: 82000
#include <cstdio>
#include <iostream>
#include <map>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__)
inline char nc()
{
    return getchar();
    static char buf[100000], * l = buf, * r = buf;
    if(l == r) r = (l = buf) + fread(buf, 1, 100000, stdin);
    if(l == r) return EOF;
    return *l++;
}
template<class T> void readin(T & x)
{
    x = 0; int f = 1, ch = nc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
    while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
    x *= f;
}
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int n, m;
char s[100050], t[100050];
map<int, char> p;
int main()
{
    readin(n), readin(m);
    scanf("%s", s);
    scanf("%s", t);
    long long ans = 1ll * n * m / gcd(n, m);
    for(int i = 0; i < n; i++)
    {
        p[ans / n * i + 1] = s[i];
    }
    for(int i = 0; i < m; i++)
    {
        long long x = ans / m * i + 1;
        if(p.count(x) && p[x] != t[i])
        {
            puts("-1");
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
static const int64_t MAX_N = 1E5, MAX_K = 100, INF = 1e10;
int64_t n, k, h[MAX_N], dp[MAX_N];

int64_t cost(int64_t i, int64_t j) {
	return abs(h[i] - h[j]);
}

void solve() {
	for(int64_t i = 0; i < n; i++) {
		dp[i] = INF;
	}
	dp[0] = 0;

	for(int64_t i = 0; i < n; i++)  {
	for(int64_t j = 1; j <= k; j++) {
		int64_t x = i - j;
		int64_t a = dp[x] + cost(i, x);
		if(0 <= x && x < n && dp[i] > a) dp[i] = a;
	}
	}
	cout << dp[n-1] << endl;
}

int main() {
	cin >> n >> k;
	for (int64_t i = 0; i < n; i++) {
		cin >> h[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using std::swap;

// priceをキーに降順でソート
//sort(fruits.begin(), fruits.end(),
//     [](const fruit& x, const fruit& y) { return x.price > y.price;});

/*
int main() {
    vector<char> s;
    string S;
    std::cin >> S;
    for(int i=0; i<4; i++){
        s.push_back(S[i]);
    }
    std::sort(s.begin(), s.end());
    if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[3]){
        std::cout << "Yes" << std::endl;
        return 0;
    }
    else{
        std::cout << "No" << std::endl;
        return 0;
    }
}
*/

int main(){
    int N;
    std::cin >> N;
    int a[N];
    int count =0;
    for(int i=0; i<N; i++){
        std::cin >> a[i];
    }
    for(int i=1; i<N-1; i++){
        if((a[i]-a[i-1])*(a[i]-a[i+1])<0){
            count++;
        }
    }
    std::cout << count << std::endl;
    return 0;
}

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

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

    vector<int> k(m);
    vector<vector<int>> s(m);
    vector<int> p(m);

    rep(i, m){
        cin >> k[i];
        rep(j, k[i]){
            int tmp;
            cin >> tmp;
            s[i].push_back(tmp);
        }
    }
    rep(i, m) cin >> p[i];

    int ans = 0;

    vector<int> sw(n);

    for(int i=0;i<pow(2,n);i++){
        bool flag = 1;
        int tmp = i;

        for(int j=n-1;j>=0;j--){
            sw[j] = tmp % 2;
            tmp /= 2;
        }

        //cout << sw[0] << sw[1] << endl;

        for(int j=0;j<m;j++){
            int sum=0;
            for(int l=0;l<k[j];l++){
                sum += sw[s[j][l]-1];
                //cout << s[j][l]-1 << ": " << sw[s[j][l]-1] << endl;
            }
            //cout << sum << p[j] << endl;
            if(sum % 2 == p[j]) flag *= 1;
            else flag *= 0;
        }

        if(flag) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int t[300000];
int c[300000];

int root(int x){
  if(t[x]==x) return x;
  return t[x]=root(t[x]);
}

int main(){
  int N,M;
  scanf("%d %d",&N,&M);
  for(int i=1;i<=N;i++){
    t[i]=i;
    c[i]=1;
  }
  int A,B,RA,RB;
  for(int i=1;i<=M;i++){
    scanf("%d %d",&A,&B);
    if(A>B){
      A^=B;
      B^=A;
      A^=B;
    }
    RA=root(A);
    RB=root(B);
    if(RA!=RB){
      t[RB]=RA;
      c[RA]+=c[RB];
    }
  }
  int Ans=0;
  for(int i=1;i<=N;i++){
    if(Ans<c[i]) Ans=c[i];
  }
  printf("%d\n",Ans);
  return 0;
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

int main()
{
    ll n;
    cin >> n;
    vector<pair<P, ll>> height;

    ll index;
    rep(i, n)
    {
        ll x, y, h;
        cin >> x >> y >> h;
        height.push_back({{x, y}, h});

        if (h != 0)
            index = (ll)(height.size() - 1);
    }

    //(cx,cy) 全探索
    rep(cx, 101)
    {
        rep(cy, 101)
        {
            bool center = true;
            ll H = height[index].se + abs(height[index].fi.fi - cx) + abs(height[index].fi.se - cy);

            //(cx,cy)が全部の与えられた点を満たすか
            rep(i, n)
            {
                ll num = max(0ll, H - abs(height[i].fi.fi - cx) - abs(height[i].fi.se - cy));

                if (num != height[i].se)
                    center = false;
            }

            if (center)
            {
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3600
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc  = new Scanner(System.in);
		int D = sc.nextInt();
		int N = sc.nextInt();
		if (N != 100){
			System.out.println((int)Math.pow(100,D)* N);
		}else{
			System.out.println((int)Math.pow(100,D)* (N+1));
		}
		sc.close();
	}
}

Measured memory_bytes: 22484
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fi first
#define se second
using ll=long long int;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
	ll n;
	cin>>n;
	string s;
	cin>>s;
	map<char,ll>mp;
	rep(i,n){
		mp[s[i]]++;
	}
	ll sum=1;
	for(auto x:mp){
		sum*=x.second+1;
		sum%=mod;
	}
	cout<<sum-1<<endl;
	return 0;
}




Measured memory_bytes: 512
import math

a,b, C = map(int, input().split())
C = math.radians(C)
S = (a * b * math.sin(C))/2
l = a + b + math.sqrt(a**2 + b**2 - 2*a*b*math.cos(C))
h = b * math.sin(C)
print(S)
print(l)
print(h)

Measured memory_bytes: 7860
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, W, WV):
    items = defaultdict(list)
    for w, v in WV:
        items[w].append(v)

    for w in items:
        items[w].sort(reverse=True)

    for i in range(4-len(items)):
        items[-i] = []
    ws = list(items.keys())

    @lru_cache(maxsize=None)
    def f(rw, i, j, k, l):
        ret = 0
        if ws[0] <= rw and i < len(items[ws[0]]):
            ret = max(ret, f(rw - ws[0], i+1, j, k, l) + items[ws[0]][i])
        if ws[1] <= rw and j < len(items[ws[1]]):
            ret = max(ret, f(rw - ws[1], i, j+1, k, l) + items[ws[1]][j])
        if ws[2] <= rw and k < len(items[ws[2]]):
            ret = max(ret, f(rw - ws[2], i, j, k+1, l) + items[ws[2]][k])
        if ws[3] <= rw and l < len(items[ws[3]]):
            ret = max(ret, f(rw - ws[3], i, j, k, l+1) + items[ws[3]][l])

        return ret

    return f(W, 0, 0, 0, 0)


def main():
    N, W = read_int_n()
    WV = [read_int_n() for _ in range(N)]

    print(slv(N, W, WV))


if __name__ == '__main__':
    main()


Measured memory_bytes: 115540
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine().split(" ")[1];

        PrintWriter out = new PrintWriter(System.out);
        out.println("A" + s.charAt(0) + "C");
        out.flush();
        sc.close();
    }
}

Measured memory_bytes: 38624
#include<stdio.h>
int main(){
int a, b, c;
char op;
scanf("%d %c %d", &a, &op, &b);
while( 1 ){
if ( op == '+' ){
c = a + b;
printf("%d\n",c);
} 
else if ( op == '-' ){
c = a - b;
printf("%d\n",c);
} 
else if ( op == '*' ){
c = a * b;
printf("%d\n",c);
} 
else if ( op == '/' ){
c = a / b;
printf("%d\n",c);
} 
else {
break;
}
scanf("%d %c %d", &a, &op, &b);
}
return 0;
}


Measured memory_bytes: 2128
#2020-03-19
n,m = map(int,input().split())
nm = [[0 for i in range(m)] for j in range(n)]

sum = [0 for i in range(n)]

for tate in range(n):
    nm[tate] = list(map(int,input().split()))

mg = [int(input()) for i in range(m)]
for x in range(n):
    for y in range(m):
        sum[x] += nm[x][y] * mg[y]
for x in range(n):
    print(sum[x])


Measured memory_bytes: 6028